Phpstorm Drupal



Phpstorm DrupalEvents

PhpStorm for Drupal Debugging Drupal modules and themes (or Drupal core itself) can be challenging without a good IDE. After using numerous IDE and text editors, PhpStorm has earned its place as my primary IDE for almost anything Drupal-related. By default, PhpStorm is as Drupal. 1) Set up a project for Drupal 8 in PHPStorm. Open PHPStorm and select 'Create New Project from Existing Files'. In the next screen, select 'Web server is installed locally, source files are located under its document root.' And press 'Next'. In the next step, PHPStorm will ask you to select the root folder of the Drupal. One of the great advantages of an IDE over a text editor is the ability to easily run a debugger. In this lesson you'll learn how to configure PhpStorm to use XDebug. We'll walk through getting XDebug set up, and then how to debug, including setting breakpoints. Note: From the menu bar, PhpStorm Preferences PHP Debug will apply settings to the current project as described in the video.

Drupal

The PhpStorm team is up for the April-May round of conferences and eager to meet you there! We’ll be visiting Lone Star PHP (April 7-9), WordCamp London (April 8-10), DrupalCon New Orleans (May 9-13), PHPDay Italy (May 13-14), and php[tek] (May 23-27).

Lone Star PHP, April 7-9 (Dallas, TX, US)

This organization is a Drupal services provider. PhpStorm is the smartest PHP IDE that actually gets your code. Supports PHP 5.3/5.4/5.5, modern & legacy projects. On the fly error prevention. In PhpStorm, make sure phone button (“Start listening for PHP debug connections”) is enabled. Install Chrome extension Xdebug Helper. Leave all its settings default, you will not need to change anything for PhpStorm. Switch the grey Xdebug icon on Google Chrome toolbar to.

The Lone Star PHP Conference is a yearly conference bringing together the PHP and webrelated speakers into the heart of Texas for a three day event. It’s a great place for developers to learn with hands-on tutorial sessions, general talks and plenty of time to hang out and enjoy the company of fellow developers.

Come to visit our booth to meet our Developer Advocate, Gary Hockin. Two talks from Gary are also waiting for you at the conference!

JetBrains is raffling one Conference Ticket to LoneStar PHP – please comment on this blog post stating that you want to win a ticket to LoneStar PHP. The winner will be selected randomly on April 3rd.

WordCamp London, April 8-10 (London, UK)

WordCamp London is a community organised WordPress event running for the third year since 2013. It’s aimed at anybody who uses, builds or has an interest in WordPress.

At our booth we’ll be happy to show you PhpStorm demos, answer any questions you have in mind, share information about future releases, and of course have fun!

Phpstorm drupal setup

Be sure to register for our free license raffle and grab one of our awesome yo-yos and new JetBrains fingerboards. Even if you don’t win a free subscription, we’ll send you a discount toward a new personal one-year subscription to PhpStorm.

JetBrains team: Alexey Gopachenko (Project Lead)

Phpstorm Php Interpreter

DrupalCon New Orleans , May 9-13 (New Orleans, US)

DrupalCon brings together thousands of people from across the globe who use, develop, design, and support the Drupal platform.

DrupalCon is the heartbeat of the Drupal community, where improvements to the project are made, where important business connections are built, and where lifelong friendships bloom. Twice a year, the Drupal community gathers in North America, Europe, and a third geographic region, and joins together for a full week dedicated to sharing and growing Drupal skills.

The North American DrupalCon is the most widely attended Drupal event in the world. Taking place in New Orleans, Louisiana this year, DrupalCon New Orleans will feature a full schedule of educational, networking, and contribution opportunities.

PhpStorm team will be happy to meet you at our booth! We will show you PhpStorm demos, answer your questions, share information about future releases, and enjoy the conference together with you! We will also show how to play with yo-yos and will hold a free license raffle.

JetBrains team: Anna Lebedeva (Product Marketing Manager), Maxim Kolmakov (QA Engineer), Elena Shaverdova (Software Developer).

PHPDay Italy, May 13-14(Verona, Italy)

phpDay is the first historic Italian conference dedicated solely to PHP development, technologies and management. It is aimed to IT managers, developers and innovators.

During the conference you will explore new development traits, best-practices and success cases related to quality, revision control, test-driven development, continuous integration and so on. There are also talks about design, project management, agile and various php-related technologies, such as Zend Framework2, Symfony2, Laravel, Drupal, WordPress.

PhpStorm will support the event as a Gold sponsor. We look forward to seeing you there for a fun time together.

php[tek], May 23-27 (St. Louis, MO, US)

php[tek] as a professional conference with a community flair, which has been running as an annual PHP & web technology conference since 2006.

Autocomplete

php[tek] brings together great technology content and great people. You will find a high-quality presentations by the brightest experts in the PHP world, coupled with a welcoming and friendly community of attendees and speakers.

PhpStorm team will be happy to meet you at our booth answer your questions, share information about future releases, and enjoy the conference together with you!

JetBrains team: Gary Hockin (Developer Advocate), Svetlana Zemlyanskaya (Software Developer).

See you soon!

Keep up with the latest PhpStorm news on our blog and follow us on Twitter @phpstorm.

The Drive to Develop
– JetBrains PhpStorm Team

Introduction

XDebug with PHPStorm can do step-debugging on remote sessions started from the command line on a remote machine. You just have to set up a couple of environment variables, map the remote code to the local code that PHPStorm has at its disposal, and tunnel the xdebug connection to your workstation.

Note: If you just want to debug a PHP script (or drush command) on the local machine, that's much easier. Just enter PHPStorm's Run/Debug configuration and create a new 'PHP Script' configuration.

Overview of Setup

  • We'll create a PHPStorm project that contains all the code we want to debug on the remote machine. This can be done via source control with matching code, by mounting the remote directory to your local machine, or any way you want.
  • Create a mapping from server side directories to PHPStorm-side code (A 'Server' configuration in PHPStorm)
  • Use environment variables on the remote machine to tell xdebug what to do with the debugging session
  • Tunnel the Xdebug TCP connection if necessary.
  • Make PHPStorm listen for a connection
  • Create a breakpoint somewhere early in the execution path
  • Run the command-line tool on the remote server.

Step-by-Step

Phpstorm Wordpress Development

  1. On the remote server install xdebug and set xdebug.remote_enable=1 In your xdebug.ini (or php.ini). For complete details see Remote Drupal/PHP Debugging with Xdebug and PHPStorm.
  2. Open your project/directory in PHPStorm; it must have exactly the same code as is deployed on the remote server. (You can optionally mount the remote source locally and open it in PHPStorm using sshfs or any other technique you want, see notes below.)
  3. If you're debugging drush, you probably need to copy it into your project (you don't have to add it to source control). PHPStorm is quite insistent that executing code must be found in the project.
  4. Create a debug configuration and a 'Server' configuration in your project. The Server configuration is used to map code locations from the server to your PHPStorm code. Run->Edit Configurations, Create PHP Web App, Create a server, give the server a name. Click 'Use path mappings' and configure the mappings from your project to the remote server's code. (See )
  5. If your remote server cannot directly create a tcp connection to your workstation, you'll have to tunnel port 9000 to your local machine. ssh -R 9000:localhost:9000 your_account@remote_server.example.com - For more details and debugging, see
  6. Click the 'Listen for PHP Debug Connections' button in PHPStorm. I call this the 'unconditional listen' button, because it makes PHPStorm listen on port 9000 and accept any incoming connection, no matter what the IDE key. See Remote Drupal/PHP Debugging with Xdebug and PHPStorm
  7. In PHPStorm, set a breakpoint somewhere that your PHP script is guaranteed to hit early in its execution. For example, if you're debugging most drush actions, you could put a breakpoint on the first line of drupal_bootstrap() in includes/bootstrap.inc.
  8. If the computer is not reachable from the server, you will need to tunnel the connection from the server to your workstation. ssh -R 9000:localhost:9000 some_user_account@www.example.com For more details and debugging, Remote Drupal/PHP Debugging with Xdebug and PHPStorm
  9. In your command-line shell session on the remote server set the environment variable XDEBUG_CONFIG. For example, export XDEBUG_CONFIG='idekey=PHPSTORM remote_host=172.16.1.1 remote_port=9000' (Note that port 9000 is the default both for xdebug and for PHPStorm.) If you're tunneling the connection then remote_host must be 127.0.0.1. If you're not tunneling, it must be the reachable IP address of the machine where PHPStorm is listening.
  10. export PHP_IDE_CONFIG='serverName=yourservername' - the serverName is the name of the 'server' you configured in PHPStorm above, which does the mapping of remote to local paths.
  11. On the command line run the command you want to run. For example drush cc all or php /root/drush/drush.php status
  12. If all goes well you'll stop at the breakpoint. You can step-debug to your heart's content and see variables, etc.

Drush+Drupal-Specific Hints

  • I've had the best luck actually copying drush into my codebase so that its mappings and Drupal's mappings can be in the same directory.
  • Once you have the environment variables set you can either use the 'drush' command (which must be in your path) or use 'php /path/to/drush/drush.php' with your drush options. Make sure you're using the drush that's mapped as a part of your project.
Phpstorm

Notes and resources

  • We set the xdebug.remote_host in the XDEBUG_CONFIG environment variable; it could also have been configured in the xdebug.ini as xdebug.remote_host=myworkstation.example.com. (Note that the default is 'localhost', so if you're tunneling the connection you don't actually have to set it.)
  • Full details about remote debugging on xdebug.org
  • Debugging: Make sure that only PHPStorm is listening on port 9000. If something else (most notoriously php-fpm) is listening there, you'll have to sort it out. PHPStorm is happy to listen on another port, see the preferences, and you'll need to change your environment variable to something like export XDEBUG_CONFIG='idekey=PHPSTORM remote_host=172.16.1.1 remote_port=9999
  • You may want to use sshfs or some other technique to mount the remote code to your local machine. sshfs your_account@server.example.com:~/drush /tmp/drush would mount the contents of drush in the remote home directory to /tmp/drush (which must already exist) on your local machine. It must be writeable for PHPStorm to work with it as a project, so you'll have to work that out.
  • The article that taught me everything I know about this is Command-line xdebug on a remote server. Thanks!