Just below, we see that the line of the breakpoint is highlighted this is to show that the code has stopped here like expected. $_locale is "en", $goals is an array with two keys, and lastly, $articleRepository is the Doctrine repository of the Article entity. First, after the controller method declaration line, we have the values of the parameters received by the action. If it works, PHPStorm gets back as the active window of your OS, and you get the following output:Īs you can see, the code window is different from what we use to have. Now, open your browser and access a page that calls the action where we put the breakpoint. A red disc □ appears like this (at line 33 in this example): Open one of your controllers and click between the line number and the start of the code editor panel of the line you want to stop the execution. Now that PHPStorm has validated our setup let's try to add our first breakpoint. It must be done with the Run > Start Listening for PHP Debug connections menu entry. The final step is to tell PHPStorm to start listening to Xdebug connections. You can ignore the error of the last line, it seems to be a known problem, but it won't prevent the debugger from working. If everything is OK, you should see ✅ like above. In the second parameter, put the local URL of your project. In the first parameter put the full path of your project public directory where is stored the Symfony front controller (generally public/index.php with Symfony 5). Open the menu entry: Run > Web Server Debug Validation. Now, let's check the configuration inside PHPStorm. Check out the xdebug.remote_host and xdebug.remote_port parameters in the documentation. So, with this setup, the port used by Xdebug is 9000 and the default IP address is 127.0.0.1. We keep the other default parameters to keep the configuration as minimal as possible. Add the following parameter in your PHP configuration as we did previously: Now that Xdebug is activated let's see how to configure it for PHPStorm.įirst, we must enable the remote option of Xdebug. ![]() The debug bar also shows if Xdebug is available when you pass over the Symfony version number with your mouse: With Zend OPcache v7.4.6, Copyright (c), by Zend Technologies ![]() With Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans Zend Engine v3.4.0, Copyright (c) Zend Technologies If everything is OK, you should now see Xdebug when getting the PHP version: You must see a line like the following (it can also be loaded in an external file like conf.d/ext-xdebug.ini): Verify that in this file, the xdebug.so (or. Loaded Configuration File => /usr/local/etc/php/7.4/php.ini You can find this file by running:Ĭonfiguration File (php.ini) Path => /usr/local/etc/php/7.4 If not done, activate the Xdebug extension in your php.ini file. So first let's install Xdebug, it can be done with PECL: I will assume you have a working PHP/Symfony installation. If you use another type of setup (Apache, Docker.), you'll probably have to make small adjustments to the following instructions. Here, I use the Symfony binary to serve my application. I use the following configuration, but it should be OK with previous versions of each of these components. But what about transforming something negative to something positive and useful? □ That's why I decided to write this blog post. We don't know if the tweet is pure sarcasm or not. “If you don't use Xdebug, you aren't a real developer.” □Įven it's not what Derick meant to say, it's what people may understand. It brings negativity as It can be interpreted by people not using Xdebug by: This is the kind of tweet I don't like, a typical troll, trying to make a generality of something more complex. PHP developers that don't use Xdebug for debugging are amateurs. Why this blog post? Well, because of this tweet: ![]() I will assume you have a basic knowledge of PHP, Symfony and that you know how to modify your PHP configuration thanks to the php.ini file. » Published in "A week of Symfony 704" (22-28 June 2020).
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |