[PHP] Xdebug
Xdebug
PHP extension์ด๋ฉฐ ๋๋ฒ๊น
, ํ๋กํ์ผ๋ง, ์ถ์ ๋ฑ ๋ค์ํ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ค.
PHP 8 ๋ฒ์ ์ด์ ์ฌ์ฉํ ๊ฒฝ์ฐ Xdebug๋ 3 ๋ฒ์ ์ด์ ์ฌ์ฉํด์ผ ํ๋ค.
VSCode ide๋ฅผ ์ฌ์ฉํ๊ณ Docker Compose๋ฅผ ์ ์ฉํ์ฌ ๊ฐ๋จํ๊ฒ Xdebug๋ฅผ ์ค์ ํด๋ณธ๋ค.
ํ๋จ ์์ ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ
Step 1
docker-compose.yml ์์ฑํ๊ธฐ
1
2
3
4
5
6
7
8
9
10
version: '3.8'
services:
app:
build: ./docker/app
ports:
- '8080:80'
volumes:
- ./src:/var/www/html
- ./docker/app/php.ini:/usr/local/etc/php/php.ini
Step 2
docker/app/Dockerfile ์์ฑํ๊ธฐ
1
2
3
4
FROM php:8.1-apache
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
Step 3
docker/app/php.ini ์์ฑํ๊ธฐ
1
2
3
4
5
[xdebug]
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
Step 4
extension install
Step 5
launch.json ์์ฑ
Step 6
launch.json์ xdebug ์ค์
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html/": "${workspaceRoot}/src"
}
}
...
]
}
Step 7
src/index.php ํ์ผ ์์ฑ ํ ์์์ ์ฝ๋๋ฅผ ์์ฑํ๊ณ F5ํค๋ฅผ ๋๋ฅด๋ฉด ๋๋ฒ๊น ๋ชจ๋๊ฐ ์คํ๋๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.(โป ์ฝ๋ ์ค๋ฒํธ ํ์ ์ข์ธก์ ํด๋ฆญ์ ํ์ฌ break point๋ฅผ ์ง์ ํ๋ค.)
Leave a comment