This tutorial applies to users of Laravel projects and uses homestead as the virtual machine for the development environment by default.
1. Confirm that you have installed the Xdebug
By ssh
logging in homestead
to your, executing
ls /etc/php5/fpm/conf.d
If you see 20-xdebug.ini
the configuration item, the description Xdebug
is loaded correctly, as shown in the following figure:
2. Configure Xdebug.ini
Enter your directory by using the following command xdebug.ini
:
cd /etc/php5/mods-available
You can use Vim to edit it, zend_extension=xdebug.so
adding the following lines below a line:
xdebug.remote_enable = onxdebug.remote_connect_back = onxdebug.idekey = "vagrant"
Save, exit, and then rebootphp-fpm
sudo service php5-fpm restart
3. Configure Phpstorm
Open your Laravel project in Phpstorm, click on the cmd + ,
exhale preferences, find PHP
Servers
it below, and configure it as follows:
/path/to/laravel ==> /home/vagrant/path/to/laravel/path/to/laravel/public ==> /home/vagrant/path/to/laravel/public
The folders configured here correspond to the Homestead.yaml
files that are mapped. When you are finished setting, Apply.
Then go back to the navigation bar, find Run -> Edit Configurations
it, add one PHP Web Application
. As shown in figure:
4. To test
To app/routes.php
write an instance code:
Route::get('/', function(){ $a = [1, 2, 3, 4, 5]; array_pop($a);});
Then add a breakpoint to each row, then Run --> Debug
, select the previous set Homestead
, and if you see the image below, congratulations.
The above mentioned is the entire content of this article, I hope you can enjoy.