- Install docker
- Any way to install laravel https://laravel.com/docs/8.x/installation
Make sure you have the docker-compose.yml that generate by default
Execute the following script will generate a dockerfile under root directory
php artisan sail:publish
SAIL_XDEBUG_MODE=debug
Set off if you don't want to run xdebug.
For example, I want to use php 8.1 for debug. So open the php.ini from docker/8.1/ and append the following settings:
[XDebug]
zend_extension = xdebug.so
xdebug.start_with_request = yes
xdebug.discover_client_host = true
xdebug.idekey = VSC
xdebug.client_host = host.docker.internal
xdebug.client_port = 9003
./vendor/bin/sail up -d --build
- Install the extension of felixfbecker.php-debug
- Copy the launch.json to .vscode/ to config the debug extesion
- Set some break point and press F5 to start debuggin
- toolbar > run > Start listening for PHP debug connections
- Open link http://localhost/ and the PHPStorm will pop up a window to let you setup Xdebug. All you need to do is click Accept button. Then setup finished.