![]() ![]() ![]() I didn't see any flashing lights or hear bells and whistles, but I should have a binary file that PHPStorm can inspect, located in the path I setup in my php.ini profiler_output_dir directive. To use the great new feature, first, you need to disable Xdebug for command line PHP scripts. To profile the node view I visited in my browser. 'Xdebug in demand' option works for CLI debugging only (Run/Debug Configuration of 'PHP Script' type will also work for other CLI-mode configs, e.g. ![]() To give you an idea of what is possible, lets profile the work required to view a simple Drupal node. For my dev site I used the php.ini config you see above and simply added a URL parameter “XDEBUG_PROFILE=on” to my site’s url this starts Xdebug profiling from the browser. For instance, if you are using Drush to run a migration, you can’t start the profiler on-demand, and that affects the profiler_trigger setting. To setup your environment, edit your php.ini file and add the following lines: xdebug.profiler_output_dir=/tmp/profiler/ĭepending on what you are testing and how, you may want to adjust the settings for your site. To get going with profiling Drupal in PHPStorm and Xdebug you need: The more work your code does, the more information that the profiler stores file sizes for these logs can get very big very quickly. Whoa there cowboy! First you need to know that the act of profiling your code is itself taking resources to accomplish. If you want to know more about memory performance tracking you should check out Xdebug’s execution trace features. Note that Xdebug’s profiler does not track memory usage. Whatever the reason, if you have been tasked with analyzing the performance of your Drupal codebase, profiling is one great way of doing so. You might need to profile your site or app if you work at a firm where performance is highly scrutinized, or if you are having problems getting a migration to complete. To stop PHPStorm opening every time you run a Drush command, simply press the telephone button again and hang up.Profiling is about measuring the performance of PHP code, at least when we are talking about Drupal and Xdebug. It takes some time to get it all set up, and then you also need to get familiar with. bash_profile file in your home directory so it's available as soon as you open your terminal. Regardless of where your config file lies, you will need to add in the following: existing stuff here xdebug.remoteenable1 xdebug.remoteport9000 xdebug.idekeyPHPSTORM123 xdebug.remoteconnectback1. Debugging with Xdebug is not everyone's favorite topic. Now you can step through the code in the same way as before.Įxecuting the export command before running Drush commands will be a little time consuming. Now, at the same command prompt where you entered the export command above, run a Drush command, for example: drush cc all If you click between the line number and the code, a red spot will appear. Maybe this is due to my Appache stack being run on MAMP Pro Chrome has JetBrains IDE Support 2.0.9 and Xdebug helper 1.6. For example, open index.php in your project and place a breakpoint next to a PHP function as shown in the image. I think this means that the CLI version is configured differently. If you have put in a breakpoint, then execution of the command will pause at that point. Now, when you run a Drush command it will be picked up by PHPStorm. In the command line where you normally run your Drush commands, first type the following command and press enter: export PHP_OPTIONS="-dxdebug.remote_autostart=On -didekey=PHPSTORM -dremote_host=localhost -dprofiler_enable=1" 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. ![]() I am going to explain how to setup your development tools so that you can debug Drush commands in real time, as they run. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |