Remote debugging and project setup from Mac client to Linux server

I recently switched to the Mac from Windows and am looking for a good PHP IDE for the Mac. I have been a long-time user of NuSphere PhpED, but that's only available on the Mac and, although I have been using it using Parallels Desktop, I'd prefer something native for the Mac. I heard great things about this software and am trying it out right now.

That said, here's my situation and plea for help:

I have a Linux server on my network that runs my web sites. I keep the server's hard drive permanently mounted on my desktop, and prefer to work and make changes in-place, i.e., directly to those files, rather than keep a second local copy and deal with uploading/downloading. As such, I'm having trouble:

(a) setting up the project correctly. If I set it up as "Web server is installed locally, source files are located under its document root", then I get the benefit of in-place editing, but I can't get the server/debugging working right, so this doesn't seem like the best option. But, every other option requires me to duplicate the files locally and deal with syncronization. Is there any way to use a remote server for debugging, but without duplicating files and instead editing them in-place using a mounted drive?

(b) getting the remote debugger to work at all. I have both Firefox and Chrome installed on my Mac. On the remote Linux server, I have Zend Debugger installed, which works fine with NuSphere PhpED. How do I get it working with PhpStorm?

Any guides or help would be greatly appreciated!!! I tried looking through many of these discussions as well as googling this, but couldn't seem to find a solution applicable to my specific situation.

I'd really love to switch to PhpStorm, but just need to get the debugging working first!

Thanks.

20 comments

Hi Paul,

This will not be full answer, since I'm not using Mac or remote debugging (only sometimes), so ...

1) Better have Local project with automatic! synchronization with remote location (all new or changed files will be automatically uploaded to remote location on Save) -- this is recommended and most optimal solution. Otherwise you may experience weird lags or similar behavior when you have delays/freeze out of nowhere (it really depends on your setup/hardware etc -- most of the time it works fine/acceptable).

2) Start here:


I see no much point jumping deeper without knowing what you have done so far and what problems you are facing.

0

Regarding the project setup, this was unfortunately no real help (but I do appreciate the effort).

First of all, there is no option for "Local project with automatic! synchronization with remote location".

The only options available are:
     * Web server is installed locally, source files are located under its document root.
     * Web server is installed locally, source files are located elsewhere.
     * Web server is on remote host, files are accessible via network or mounted drive.
     * Web server is on remote host, files are accessible via FTP/SFTP.
     * Source files are in a local directory, no Web server is yet configured.

(I am attaching a screenshot of these options, which contains a bit more description.)

Since my server is on a remote host, only options 3 or 4 are applicable. Of those, obviously the closest fit is the one where it's on a mounted drive. Even then, the description below it says "synchronized with server when necessary" and not "automatically".

Unfortunately, though, even manual syncronization wouldn't work!  After setting up the project, it successfully downloaded a local copy of the whole file structure (not ideal, but I'm taking your advice that it's the best option). Now, using the local structure, I created a few new files in PhpStorm and saved them. Of course, no automatical sync, so I wasn't surprised much there. But, when I clicked on manual sync, it said that it completed successfully—and yet, the new files did not get moved over!

Surprised, I went to the menu and chose "compared local files with deployed version" to see if there were any errors or anyhing like that. Nope. Even more strange, the screen just said, "Contents have differences only in line separators" and that's it. No mentions of entire files being different between the two locations!! (I'm attaching a screenshot of this strange status window).

In short, I spent two more hours today trying to just get a project set up and couldn't even do that. Unless there is a better method of getting help, I think I might have to remain with NuSphere's PhpEd running in Parallels. :(



Attachment(s):
2012-06-12 06.39.50 pm.png
2012-06-12 07.10.01 pm.png
0

As for debugging, I cannot even get the browser to open with the proper path.

I appear to have the mappings set correctly, as per the instructions:

Local Path: /Users/paul/PhpStorm Projects/testproj.com
Deployment Path: /docroot/ (relative to folder '/Volumes/Data (Server)/web/testproj.com')
Web Path: / (relative to web server root URL: http://testproj.com)

So, as per the configuration I have set, the web server root is configured—and yet, when I click on "Debug", it opens Firefox with the following address:
http:///

(three slashes)

Even clicking on "Edit Configations" in the debugger menu and hardcoding the full URL does not help. I am completely frustrated.

0

Hi Paul,

     * Web server is on remote host, files are accessible via network or mounted drive.
     * Web server is on remote host, files are accessible via FTP/SFTP.

One of those.

Then Settings | Deployment | Options --> Upload changed files automatically to the default server (make sure that you have marked your deployment entry as Default for this project) plus check other options there (e.g. Upload external changes to include externally changed files as well)

it successfully downloaded a local copy of the whole file structure (not ideal, but I'm taking your advice that it's the best option)

You can copy all required files to your local HDD (or SSD, whatever) manually and then use "File | Open Directory" -- this will create a project there (all project settings are stored in .idea subfolder). The rest (deployment etc) you can configure manually. But in any case -- if you are using the wizard (New Project dialogue) yu can specify what files/folders need to be removed from fetching.

Unfortunately, though, even manual syncronization wouldn't work!

How did you performed this "manual synchronization" ? Via "File | Synchronize" (3rd button on main toolbar)? If so -- it does completely different thing -- it re-reads file structure from project location (in your case -- local HDD) and checking for any missed changes (this is done automatically every time you activate IDE (e.g. coming from another window) -- this is for cases when such changes are not detected automatically). Proper way is to right click on file/folder and choosing "Deployment | Sync with deployed to YOUR_DEPLOYMENT". Just make sure you have setup correct pathes in Deployment (Mappings tab)

In short, I spent two more hours today trying to just get a project set up and couldn't even do that.


I suggest checking this link: http://www.jetbrains.com/phpstorm/documentation/index.html  ; in particular: http://www.jetbrains.com/webstorm/demos/ftp_sync.html


I'm not using those "Create new project" dialogue myself, since almost all my projects are local an even setting up remote one takes few mins (I prefer doing it manually than relying on some wizard), so cannot be sure what's may be missing, but it looks like something was not finished configuring (be it your from your side or project setup dialogue.

If you still having issues with setting up local project -- screenshots (or much better some screencast) is very welcome here. In any case -- use some very simple test project first (even dummy one) and when ready do it on real one. You have to understand -- the fact that you cannot set it up does not mean that it cannot be done -- lots of people using it just fine. Most likely some small thing is missed somewhere.

0

Please provide full paths (local and on server) and screenshots of corresponding screen(s) where it shows what data you have enetered -- as much detail as possible.

Saying"I have done everything correctly but it still does not work" does not really help here -- there is obviously something missing (especially when you have http:/// )

Also -- if you have symlinks in those remote paths -- this makes life more difficult (few more clicks to set it up).

0

The information you linked to here was helpful. I couldn't get Zend to work in Firefox on a Mac, but I was able to get XDebug to work instead, which seems to work just fine in Safari. For some reason, though, I cannot get it to work in Firefox. When I try to debug it in Firefox by clicking on the Debug button from PhpStorm, the page opens in Firefox without breaking at all.

I don't mind that terribly, because as long as I can debug my PHP code somewhere, I'm happy.

But, as a result, I do just have another small question: I can debug straight from Safari using XDebug plugin and attempting to load the page with the plugin turned on; however, if I try to click the Debug button from within PhpStorm, it only opens Firefox (which, again, I can't get to work here with XDebug on a Mac). I tried to go into "Edit Configurations..." to change the default of Firefox to Safari (since that does work), but my only options seem to be Firefox and Chrome, for some reason.

How can I get it to default to Safari for debugging?

Thank you again.

As you requested, I am attaching a video screencast of the entire setup of my project, from start to finish, include the attempts at debugging. In the video, you will see the initial directories (the remote is full, the local is empty), I then set up the project and then show the directories again (this time remote AND local are full, as should be), and then I set a breakpoint and attempt to debug. You'll see that in Safari, it works. When I click the debug button, though, to open Firefox, it doesn't work. I am uploading this just to see if you have any helpful hints, tips, advice or anything based on what you see in here.

ALSO, one more question that I spent a while trying to figure out for myself, as well as looking through your site documentation: is there a way to configure the document root to be inside of the project root and set up the proper mappings for the browser?  In other words, I want the project root to include BOTH the document root underneath it, as well as a separate directory for resource files. The mapping should have the document root as the web server root. I can't seem to make that work?  Any advice on that?

Thank you again for all the help and quick responses so far.

Message was edited by: Paul Arking to add attachment with further details.



Attachment(s):
PhpStorm Screencast.mov
0

Hi there,

How can I get it to default to Safari for debugging?

Please configure browsers available on your system at Settings | Web browsers

For some reason, though, I cannot get it to work in Firefox. When I try to debug it in Firefox by clicking on the Debug button from PhpStorm, the page opens in Firefox without breaking at all.
document.getElementById("zendRunZDE") is null (chrome://zend/content/toolbar.js:483)

Make sure that you have selected xdebug as debugger and not Zend -- most likely it sends zend debugger specific commands instead of xdebug ones:

  • Settings | PHP | Servers -- set correct debugger there


That should do. If not -- "Settings | PHP" and click on "..." button to manage PHP Interpreters and select correct debugger there.

Also -- have a look here -- you can use bookmarklets to initiate xdebug (or zend) debug session: http://www.jetbrains.com/phpstorm/marklets/

0

Thank you. I was able to get it to run in Firefox with the XDebug Bookmarklets.

If you can still let me know about the Project Root/Document Root thing, I would be very appreciative! (And, of course, if you have any helpful comments from my video, as well).

Thanks again.

0

Hi there,

In your video:
1) 01:38 -- you have choosen "JavaScript debug" -- I do not think that is what you have planned to debug...

At the same time -- the only other option offered to you by PhpStorm is "PHP Script" configuration type (which is for running/debugging local php scripts in CLI mode) -- also not good in your case.

2) 02:00 -- that is correct way for setting up zero-configuration debug

3) 02:20 -- as you can see now, the selected Run/Debug configuration is of "JavaScript debug" type -- it will not trigger PHP debugging. You can see that Debug tool window has "Scripts" tab -- it is not available in PHP Debug -- but available for JavaScript.

Just use "Run | Edit Configurations..." and create new entry of proper type (for PHP debugging)

If you can still let me know about the Project Root/Document Root thing

Unfortunately I do not understand what kind of problem you are having here -- please elaborate.

0

one more question that I spent a while trying to figure out for myself, as well as looking through your site documentation: is there a way to configure the document root to be inside of the project root and set up the proper mappings for the browser?  In other words, I want the project root to include BOTH the document root underneath it, as well as a separate directory for resource files. The mapping should have the document root as the web server root. I can't seem to make that work?  Any advice on that?


Thank you again for all the help and quick responses so far.

0

Thank you again for all the help. That last post was VERY helpful, as I did not fully understand the different debug types!  I have now set up one of type "PHP Web Application" and that worked PERFECTLY in firefox!  :)

(I first tried "PHP Remote Debug", but then when I ran it it just said that it's waiting for connection with the IDE key... I guess that was wrong since my PhpStorm is installed locally and my server is installed remotely--that made me think that I needed Remote Debug, but it looks ilke I just needed the PHP Web Application!)

This was really very helpful, and your response time is unbelievable!

0

For example, I use Propel ORM, which requires several directories outside the document root, and they are specific just to this project. I want to be able to have them in the Project Root to be able to automatically upload (deploy) for new changes that I will need to make, but they are not part of the document root (i.e., the / root on the web server).

So, to illustrate that:

---Project Root
  +---Document Root (this is the root of the web server)
  +---Propel Resources
  +---Other Resources (graphic art files, etc.)

All those files need to be managed in the file browser section of PhpStorm and able to be edited and deployed, but the web server needs to map to only the Document Root, so that if I try to debug a file within that Document Root, it will open with a properly constructed URL.

Thank you again!

0

Hi there,

I first tried "PHP Remote Debug", but then when I ran it it just said that it's waiting for connection with the IDE key... I guess that was wrong

No -- it is still OK to use. This option is something between zero-config and "PHP Web Application" -- it launches debugger and desired page/url in browser, but in normal mode so you have to activate debug session in browser via bookmarklet etc and sets PhpStorm to accept debug connections with specific ide key (session id) ONLY.

0

Hi there,

Well .. I see few possible ways of doing this (since I do not know what exactly you have there I cannot say which one is good for you)

1. The one I would use. It may not work well for you, but let's see:

Setup new project, but choose root folder as Project Root instead of "docroot" (00:54 in your video) and mark "docroot" as "Resource Root". This will include ALL of those extra folders inside "Project Root" folder. That is the only difference at this stage.

There will be no issues  (should not be -- I have none) with debugging, but may be (most likely) issues if you want to use "Open this file in browser" functionality, since there will be 1 extra folder difference when mapping file in project to web URL. As long as you do not use that you should be just fine. I'm using such approach with nice URLs (e.g. "www.example.com/account/new" --> "ProjectRoot/docroot/account_new.php") so that "Open this file in browser functionality does not make too much use for me, and everything is good.

2. Another possible approach (have not used/tested myself, so no guarantees) -- use your current setup and add those extra folders as additional Content Roots (Settings | Directories) and after that setup proper path mappings in Deployment (2nd tab -- 03:17 -- "Add another mapping" button).

0

I tried the first approach, but it does not work (see the first video attached). The mappings do not seem to be good, since this approach still results in the Project Root mapping to the web server's / root.  (Also, isn't a Resource Root meant to signify files that aren't indexed? Why would I want that for my main document root?)

I then tried to modify the path mappings (see the second video attached), but I was still getting errors in the debugger regarding mapping.



Attachment(s):
Attempt to Map.mov
Approach 1.mov
0

Hi there,

I'm using #1 and having no issues.

01:08 -- when you type "?????" -- just type "/" (or just leave empty as you did -- PhpStorm will use "/" by default)
02:15 -- if you starting setting up the the "PHP | Servers" manually, then you should finish doing so -- you need to use path mappings for debugging there
02:41 -- you have not setup mappings, hence the error message with hints/links that offers you to set it up (debugging path mappings)

I suggest either finish it with manually providing path mappings for debugging .. or do not do it in advance, wait until PhpStorm will offer you do that. In the end the path mappings for debugging will be the same as in your previous video (original attempt from yesterday)

2nd video:

00:09 -- I would leave it as is (no need to add "docroot") -- that one should screw it up
00:49 -- yes, that is the place where you setup path mapping for debugging (2nd column is editable -- just type the path there; if 1st column is too small -- just make window wider and resize columns to see whole line). From what I understand it should be:
/Users/paul/PhpStorm Projects/barkaiboard.org  <-->  /data/web/barkaiboard.org

0

Hi again!

As always, let me first thank you for continuing to remove the clouds from my eyes ;)

BTW, when I typed "?????", it was just to let you know that I had no idea what to put there (yes, I did leave it blank, as you said), because by leaving it blank that seemed to be mapping the web root / to the parent directory of the real docroot, since that was what was in the server path supposedly corresponding to it.

So, does that mean that when I do manual mappings if overrides that default web root mapping?  I guess so. I guess it would just be a little more understandable if there was a way to specify both a project root and and document root (in NuSphere's PhpEd setup, you can do that by specifying during project setup if the document root resides within the project root, or is the same as the project root—as well as a few other alternatives).  (Maybe you can "borrow" some ideas from them just to make the setup a bit smoother? ;))

Regarding the manual PHP | Servers setup, I see now what you mean. I was having trouble figuring that part out, as well. I kept thinking that I was supposed to put the path to the server as it is mounted remotely on my machine. That's what I kept doing wrong while going through trial and error. Now, becuase you were really helpful and even spelled out the exact path for me (yes, you were correct about the path on my server), now I realize that I was supposed to put the path as it is mounted on the remote machine itself. Whew!

So, using all those suggestions, I was able to get it all to work exactly the way I wanted it to, with the project root being the WHOLE project, including non-public directories, and the document root below that, mapped properly, and the debugger to work properly in both Firefox and Safari with XDebug... the whole shebang haha. THank you!

I am attaching a video of the whole setup, which I was able to do--and test--in under 3 minutes flat!  (I guess going through the motions 40 or 50 times helps with that haha).

I guess the only question I have is as follows:  in the video, you will see that I left the deployment mappings as follows:
   Local path: /Users/paul/PhpStorm Projects/barkaiboard.org
   Deployment path relative to /Volumes/Data (Server)/web/barkaiboard.org: /
   Web path on server: /

Even though this is obviously wrong (since the first two map properly, but the web path does not), everything still works fine so far. Is that because the PHP | Server setting were set up with different mappings that I guess override this?  Or is it for another reason?  Or, maybe, is there something still not 100% right that I may not find out until later?

Thank you again for standing behind your product so diligently!!!



Attachment(s):
Final working setup.mov
0

Hi there,

Sorry -- you are wrong in your assumption about me :p

I guess it would just be a little more understandable if there was a way to specify both a project root and and document root (in NuSphere's PhpEd setup, you can do that by specifying during project setup if the document root resides within the project root, or is the same as the project root—as well as a few other alternatives).  (Maybe you can "borrow" some ideas from them just to make the setup a bit smoother? ;))

Yes, I'm missing such option as well. I think NetBeans has it as well (although I'm unsure -- have not used it for a long time, and even when I used it was rather quick overview for just a few days).

Check Issue Tracker and file new Feature Request if there is no such ticket already (as far as I'm aware there is none). If you describe your scenario (which is quite common -- move all code outside of website root for additional security) and if ticket will grab some votes, it may get implemented soon. For me, the current setup works ok -- all I have to do is to forfeit/scrap usage of "Open in browser" or similar feature(s) as project root does not match the website root.

Before doing that I would highly recommend creating new thread on forum -- maybe there is good way of setting this up even in current version -- I'm pretty sure developers know their own product better than ordinary users.

Is that because the PHP | Server setting were set up with different mappings that I guess override this?  Or is it for another reason?  Or, maybe, is there something still not 100% right that I may not find out until later?

Deployment mappings (Settings | Deployment) and PHP debugging mappings (Settings | PHP | Servers) are two different things:

  • First one uses paths as you see them from your dev computer (local physical path + remote login/path/address details) and is used for deployment only (well, considering there is field for web address -- and for URLs as well)
  • Second one uses physical local path (on your dev computer) + physical remote path (from remote computer point of view). At the end of the day xdebug (and any other debugger) works with physical files and not URLs (web server (Apache, IIS, nginx etc) is responsible for translating web URLs into local file system paths). This is why you will need to use debugging mappings if your remote paths contain symbolic links as debugger will resolve symbolic link to real file name, which at the end may be located in completely different place, way outside of your website folder. This mapping also comes handy even for complete local development (when project and web server are on the same computer) -- symbolic links will still work the same way.
0

Sorry -- you are wrong in your assumption about me :p

Wait--you do not work for jetbrains?!  Oh my goodness, they definitely owe you a LOT of "customer support" paychecks--not to mention sales commission, because if you hadn't helped me get through this, I would not be buying their product!!  I am very surprised and even more grateful for all your help. You truly are a very generous and helpful person.

Check Issue Tracker and file new Feature Request if there is no such ticket already (as far as I'm aware there is none). If you describe your scenario (which is quite common -- move all code outside of website root for additional security) and if ticket will grab some votes, it may get implemented soon. For me, the current setup works ok -- all I have to do is to forfeit/scrap usage of "Open in browser" or similar feature(s) as project root does not match the website root.

Before doing that I would highly recommend creating new thread on forum -- maybe there is good way of setting this up even in current version -- I'm pretty sure developers know their own product better than ordinary users.

You mean to set up a new thread here on this forum? Or is there another forum I'm not aware of?  I will do that, and see what people say, but yes, recommending it on their Feature Request tracker might ultimately be a good idea, as I'm sure with the different MVC and ORM modules out there, there is an increasing amount of people developing *outside* the public document root.

Deployment mappings (Settings | Deployment) and PHP debugging mappings (Settings | PHP | Servers) are two different things:

  • First one uses paths as you see them from your dev computer (local physical path + remote login/path/address details) and is used for deployment only (well, considering there is field for web address -- and for URLs as well)

I think that's what had me confused so much from the start: that there is a field for web address, but it's not really used for anything, since the PHP|Servers setup is used instead. Whew!!!!!  I feel like I just completed a really long journey. :)

Thank you for leading the way!

0

Andriy's contribution to the community is unmatched indeed and we really appreciate his efforts.

0

Please sign in to leave a comment.