![]() ![]() Breakpoints can be set in the PHP context inside PHP, HTML, TWIG, BLADE, and files of other types. On the PhpStorm toolbar, toggle to start listening for incoming PHP debug connections, or choose Run | Start Listening for PHP Debug Connections from the main menu. Read the documentation on the twig_xdebug page for some additional information as well.įrom the drupal.With the debugging engine installed, you can start debugging by following the zero-configuration debugging approach:Ĭhoose and install the browser extension suitable for your browser. Note: I’ve noticed that PHPStorm doesn’t always automatically get the focus so I just switch back and forth until I see the debug panel paused.įrom her you can inspect all of the variables available to the template. If all goes well, PHPStorm should catch the breakpoint and you can then debug the variables available to the twig template. Then, clear the registry via $ drush cr, switch back to chrome, make sure you have “Debug” selected in the chrome extension, and you are listening for xdebug connections from within PHPStorm and refresh the page. You do that by adding ` ` to a twig file you know is loading. $ drush en -y twig_xdebug or you can enable it at /admin/modulesĪfter that, we can add a “breakpoint” in the twig template. Now that we have xdebug installed, we’ve verified it’s working, and we have the twig_xdebug module installed, we next need to enable the module.įrom within the VM, navigate to the docroot folder and run: You should now be able to run the composer require command above to install the module. Look for the loaded Configuration file and open that up, search for “memory_limit” and increase the memory to at least 2048M. The easiest way to do this is to first find which ini file is being loaded by running: If you run into a php memory error like I did, you will need to increase the memory_limit in your php.ini file. $ composer require -dev drupal/twig_xdebug In theory, you should just be able to run: To continue execution, you would press the green play button or to stop execution you would click the stop icon in the debugger panel.īack on your host machine, open a terminal window and navigate to your project root, where your composer.json file exists. You can then use your debugger to inspect the available php variables. If all goes well, PHPStorm will listen for the xdebug connection and “catch” the request on the line you added the breakpoint to. Jump back to chrome and navigate to your site’s homepage. Start Listening for Debug Connections: Click the icon on the top that looks like a “old-timey” phone handset with a crossed out red circle at the top and little green bug at the bottom. Add a breakpoint somewhere by clicking in the gutter, to the left of the code, and to the right of the line numbers. Install the chrome xdebug helper extension if you don’t already have it installed.īack in PHPStorm, navigate to your Drupal project index.php file. Let’s test to see that xdebug is running. On the following screen, you can just click “ok”. You may get an RSA warning that you can ignore and click yes. PHPStorm will automatically fill in the remaining settings after which you can just click ok. In my case it’s the box folder for my project. Click on the plus icon, choose “Remote” and then select the “Vagrant” radio button and navigate to the “Vagrant Instance Folder”. Hint: type “CLI Interpreter” in the search field to find this quicker. Click the “…” to the right of the CLI Interpreter field. Open up the PHPStorm Preferences (⌘ + ,) and go to Languages & Frameworks > PHP. Next, we will need to setup PHP to use the remote interpreter on your VM. The next step is to get PHPStorm setup to listen to xdebug breakpoints.įirst, make sure your VM is running - $ vagrant up. If xdebug is running, you should see a bunch of lines related to xdebug on the screen. In your terminal window, ssh into the Virtual Machine (VM) with: $ vagrant ssh and run $ php -i | grep xdebug. Save config.yml and then open the terminal app, navigate to the same folder that your config.yml file lives in, and run: # Use PHPSTORM for PHPStorm, sublime.xdebug for Sublime Text. XDebug is disabled by default for better performance. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |