![]() Configuring Drush to tell PHPStorm it is running Click the telephone button in PHPStorm so it starts listening for executed code. Drush should now be listed as an external library.ģ. Select the folder and click OKand OK again. Now use the file brower to find where Drush is installed on your system. Click the plus button in the bottom left of the PHP popup window. In the project pane, double click external libraries, which appears at the bottom of the directories.Ģ. ![]() This will allow you to view the Drush code within PHPStorm so you can add break points to it later.ġ. Add Drush code to PHPStormĭrush can be added to PHPStorm as an external library. You will need to have configured your PHPStorm as described in the first blog post. This allowed you to set breakpoints and inspect the value of variables at specific points in the code. In a previous blog post I outlined how to configure PHPStorm and Xdebug so you can step through the code of a webpage as it is executed. I've tested these instructions on Mac OSX. Nevertheless, there is more to it, you can have Drush, PHP Unit and more integrations with PHPStorm.I am going to explain how to setup your development tools so that you can debug Drush commands in real time, as they run. Up to this point, you should have a functional PHPStorm + Xdebug configuration. Refresh your browser and the debugger will show up with the index.php variables. Now, create some breakpoints and start listening for Xdebug connections. $ cat /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini NOTE: You will have to tell to PHPStorm the path of the Xdebug.so file, you can get that by running these commands: $ lando ssh On PHP language level, we tell PHPStorm that we will be using PHP 7.4 You can get there by clicking on: configuration -> Languages and Frameworks -> PHP Let's breakdown the PHPStorm configuration is a series of steps: You should uncheck all the breakpoints selected per default and only leave the ones you have marked in your code.įor some reason, the default breakpoints do not work with Drupal. ![]() NOTE: On the Breakpoint section (bottom left in the image above), Everything is marked as default. You should end up seeing something like this: Go to the debugger section on VSCode and run the option which says: Listen for XDebug.įinally, go to your Lando site and refresh your browser. This is a Gist for the launch.json file esnaremaussa/launch.jsonįor testing purposes, you can go to the index.php file and add $test = 1 and add that line as a breakpoint in VSCode. Note: in the port section, make sure is the same port added in the php.ini file. vscode in the root of your application and create the launch.json file with the following code: This plugin can be found here: PHP Debug.Ĭreate the folder. Make sure have installed the PHP Debug plugin. ![]() Up to this point, you should be able to run lando start and have a Drupal 9 site up and running with Xdebug listening on port 9000.įor the second part, we will be configuring the most popular IDEs among PHP developers, VSCode and PHPStorm.Ĭonfiguring VSCode with Xdebug is very simple, all you have to do is following these steps: Trust me, changing the port when experiencing problems with Xdebug may just fix all your problems and save you a lot of time wandering around. Right now, as configured above, the xdebug.log file will be located at the root of the application. The name can be anything and be located anywhere within your working directory. Very handy when things don't work as expected. The xdebug.remote_log flag is used for defining the location of the Xdebug logs. Nevertheless, if you run into issues with Xdebug, don't' hesitate to change the port to 9001 (or anything, really) and rebuild lando. Xdebug will be listening on port 9000 per default. ![]() Nevertheless, these two configuration items are very important, especially when experiencing problems with Xdebug: This is a very generic configuration for Xdebug and everything should work out of the box after running lando start. This is a Gist for the php.ini file esnaremaussa/php.ini Enter fullscreen mode Exit fullscreen mode ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |