This demo is to show how to test the Swoole debugger yasd with Phpstorm.
- In Phpstorm, please
- Update Xdebug settings under Languages & Frameworks > PHP > Debug > Xdebug:
- Debug port:
9000
- Option "can accept external connections" is checked.
- Debug port:
- Add a new server
- Name: demo
- Host: 127.0.0.1
- Port: 80
- Debugger: Xdebug
- Check checkbox "Use path mapping", and map the root directory of this repository to
/var/www
(the absolute path on the server).
- Update Xdebug settings under Languages & Frameworks > PHP > Debug > Xdebug:
- In Phpstorm, add some breakpoints in file server.php.
- Enable option "Start listening for PHP Debug connections" in Phpstorm.
- We use port
9000
on the host for debugging. Please make sure it's not used by any other processes. You can use commandlsof -i :9000
to check which program is using port9000
. - Use command
docker-compose up
ordocker-compose up -d
to start the container.- In file docker-compose.yml, Docker environment variable
PHP_IDE_CONFIG
is set toserverName=demo
in the container.demo
is the server name set in Phpstorm.
- In file docker-compose.yml, Docker environment variable
- After the container is started, you can use command
php --ri yasd
in the container to check yasd settings. - Visit URL
http://127.0.0.1
in your browser to start debugging.
# To start the container
docker-compose up
# (Optional) To build the Docker image.
docker build -t deminy/yasd-demo .
docker exec -ti $(docker ps -qf "name=app") env | grep PHP_IDE_CONFIG
docker exec -ti $(docker ps -qf "name=app") php --ri yasd
docker exec -ti $(docker ps -qf "name=app") cat /usr/local/etc/php/conf.d/docker-php-ext-yasd.ini
docker exec -ti $(docker ps -qf "name=app") tail -f debug.log # Only when option "yasd.log_level" is set to 0.
docker exec -ti $(docker ps -qf "name=app") sh # To get access to a shell