PHPStorm Xdebug configuration this tutorial applies to users of the Laravel project and uses Homestead as the virtual machine in the development environment by default.
1. confirm that you have installed Xdebug
Log on to your homestead through ssh and execute
ls /etc/php5/fpm/conf.d
If you see the configuration items of 20-xdebug.ini, Xdebug is correctly loaded, for example:
2. configure xdebug. ini
Run the following command to enter the directory where xdebug. ini is located:
cd /etc/php5/mods-available
You can use vim to edit zend_extension = xdebug. so and add the following lines under the line:
xdebug.remote_enable = onxdebug.remote_connect_back = onxdebug.idekey = "vagrant"
Save, exit, and restart php-fpm.
sudo service php5-fpm restart
3. configure PHPStorm
Open your Laravel project in PHPStorm, press cmd +, set outbound call preferences, find the Servers under PHP, and configure as follows:
/path/to/laravel ==> /home/vagrant/path/to/laravel/path/to/laravel/public ==> /home/vagrant/path/to/laravel/public
The configured folder varies depending on the files mapped by Homestead. yaml. Apply.
Go back to the navigation bar, find Run-> Edit deployments, and add a PHP Web Application.
4. test
Write an instance code in app/routes. php:
Route::get('/', function(){ $a = [1, 2, 3, 4, 5]; array_pop($a);});
Then add a breakpoint to each line, Run --> Debug, and select the previously set Homestead. if you see it, congratulations.
Happy Hacking