2

I am looking for a detailed setup instructions for a plugin project in PhpStorm with full comfort like quick deployment to a testing site, debugging etc.

I'm going to start with how our current project structure is and what are the issues with it.

The project folder (where it is checked out from our version control system) is e.g. C:\Projects\sampleplugin. The testing site is C:\wamp\www\wpsite, so the plugin is deployed as C:\wamp\www\wpsite\wp-content\plugins\sampleplugin.

One other important thing is that I have a clean, unzipped installation of WordPress mapped as a PHP library in my PhpStorm project so that I get code hinting etc. The PHP library is something like C:\wpsources\4.0.

In PhpStorm, I have set up a Deployment (Settings > Deployment) like this:

  • Type: Local or mounted folder
  • Folder: c:\wamp\www\wpsite
  • Web server root URL: http://localhost/wpsite
  • ... and on the Mappings tab:
    • Local path: C:\Projects\sampleplugin
    • Deployment path on server 'mydeploymentname': wp-content\plugins\sampleplugin
    • Web path on server 'mydeploymentname': /

This deployment works fine.

However, I don't know how to set up debugging (so that it works). I have this in Settings > PHP > Servers:

  • Host: localhost, port 80, debugger Xdebug
  • Use path mappings: checked
  • In the mappings section, these are the mappings:
    • C:\Projects\sampleplugin --> c:\wamp\www\wpsite\wp-content\plugins\sampleplugin
    • C:\wpsources\4.0 --> c:\wamp\www\wpsite

But the debugging doesn't work, the Validate remote environment in that dialog doesn't work etc.

Does any one of you have a fully working setup where you could do things like debug your plugin, step into WP code etc.?

  • 4
    real php developers use notepad. how is this can be even remotely specific to wordpress? wordpress doesn't have anything to do with the remote debugging features of php – Mark Kaplun Oct 30 '14 at 11:51
  • 5
    @MarkKaplun LOL at notepad. Also I don't feel this is quite off topic, the server setup (even if local server) is in scope. It is somewhat too specific too PhpStorm though. – Rarst Oct 30 '14 at 11:55
  • 1
    @Rarst agree it is border line, therefor I marked it as local problem.... will let the phpstorm experts decide whether it is related by answering it :) – Mark Kaplun Oct 30 '14 at 12:01
  • 2
    There are already questions about generic plugin development and debugging here, answers to which are usually something like "PhpStorm + xdebug work great for debugging". However, it doesn't for me so I wanted to ask this quite specific question (but hopefully useful for others as PhpStorm is one of the most popular PHP IDEs out there). – Borek Bernard Oct 30 '14 at 12:41
  • 3
    You'll need to setup xdebug in php.ini, if you haven't done so yet. Here's the PHPStorm documentation on the topic: jetbrains.com/phpstorm/webhelp/configuring-xdebug.html – Jeremiah Winsley Nov 11 '14 at 17:12
1

I am assuming that you already followed the tutorials on setting up xDebug on PHP installation and PhpStorm. Let me know if you need some help with that.

I am using xDebug Helper extension on Chrome. Install it too.

With the extension installed:

  1. In PhpStorm, go to Run > Start Listening for PHP Debug Connections.
  2. Set a breakpoint in your code.
  3. Go to Chrome and Select Debug in the small insect.

    xDebug Helper

  4. Refresh your page.

  5. Back in PhpStorm, accept the incoming connection.

    incoming connection

  6. Enjoy debugging your code.

  • Thanks Bruno. I have verified that everything looks good on my configuration (at least it looks good to me), but all I ever manage to get is "Waiting for incoming connection with ide key 'nnnnn' for some reason. – Privateer Feb 14 '15 at 21:04
0

I cheated by checking out my plugin into the wordpress plugins directory (can't remember if I tried a sim link or not), opening a PHPStorm project on the whole wordpress install and just debugged from there.

Maybe not what you wanted but I was up and running in 5 mins.

  • Please reread the bounty – Pieter Goosen Feb 9 '15 at 15:41
  • That probably would work ... but I'm looking to get it set up the way Borek has described and still have debugging. – Privateer Feb 14 '15 at 3:10
0

I'm using PHPStorm, and everything you describe should work. The only thing is that you need to install and configure xdebug via wamp to be sure it's running.

  • How did you get it to start processing at wordpress's index.php file rather than trying to run theme/plugin files directly? (assuming you have wp set up as a library) That seems to be the part escaping me here. – Privateer Feb 14 '15 at 3:08
0

My configuration is not fully functional so this isn't really an answer ... but I wanted to share my thoughts and some information on what I've tried to get this set up so far.

My setup was pretty much the same as that described by Borek.

  1. Plugins in one directory on my file system
  2. Clean WP 4.1 in another directory on the file system attached as a library (and yes, code completion and such worked fine)
  3. Local web server with plugins properly able to be deployed to it

With this setup, when I attempt to validate I receive the following error:

"Failed to execute validation script: 'Could not read from "http://testing.localhost/_intellij_phpdebug_validator.php" because it is not a file.

The "Local path to create validation script" was set to C:\sources\my_plugins\plugins\privateer-page-types (the plugin source).

Obviously, it is looking in the wrong place so I changed the mapping to the following (Settings > Build,Execution,Deployment > Deployment):

  • Local: C:\sources\my_plugins\plugins\privateer-page-types
  • Deployment on server: wp-content\plugins\privateer-page-types
  • Web path on server: /wp-content/plugins/privateer-page-types

I did this as I realized that the web path is supposed to be the web path to the project on the server.

Once I did that, going to Settings > Languages & Frameworks > PHP > Servers and selecting Validate, I had the following setup:

  • Deployment server: Local Test
  • Local path to create validation script: C:\sources\my_plugins\plugins\privateer-page-types (the local source directory)

Clicking validate now properly shows the php.ini file, xdebug, remote host, etc.

I then set up a Run/Debug Configuration:

  • PHP Web Application
  • Name: wp-root
  • Start URL: /
  • Server: Plugin Testing
  • Browser: Chrome (with the xdebug helper installed)

Starting the debugger, it sits at Waiting for incoming connection with ide key 16907 but never notices the connection.

I tried changing the port from 9000 to 8080 under Settings > Languages & Frameworks > PHP > Debug > Xdebug.Debug port ... which then prevented the xdebug from starting as I have phpstorm set to use xdebug on 8080 ( Settings > Build,Execution,Deployment > Debugger ).

At this point, things seem like they should be working, but for some reason I cannot get past "listening".

I've tried one config (noted above) with the start url as /, one with the start url as index.php, and another with the start url as the core plugin file ... all with the same result.

Anywise, maybe this will help someone ... and if I finally get it working I'll make an update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.