by PHP-Editors staff, December 2012
Website hosting has become a commodity a long time ago and with 33% of the world sites hosted by GoDaddy the selection of the host provider is relatively simple. More of a problem is using your php editor to edit, deploy and debug PHP code hosted far away in shared hosting environment where you don't have access to php.ini and Apache modules. Is PHP IDE/Editor still useful with GoDaddy Linux web hosting? With the prices of GoDaddy's shared hosting being as low as it gets we wanted to know how much of our comfort we will have to sacrifice.
We took PhpED 8.1 - the latest version of PHP IDE from NuSphere to the task. We reviewed PhpED in our php editors section before, it is one of the most advanced PHP IDEs out there and the power of their PHP debugger is something we would hate to lose in the shared hosting. The good news is - you can have the full power of good PHP IDE/Editor and run your website under the cheapest ISP plans. One of our editors is also a travel enthusiast building his website travel-circle.com - Joomla hosted in GoDaddy shared Linux account. He set up PhpED to debug his PHP code - and here the little tutorial that came out of it:
1. Create PhpED SFTP and SSH accounts.
You will need SFTP to transfer files and also help the wizard upload dbg-wizard - the server side helper for debugger installation
2. Create new project and run the wizard.
NOTE: If you were on a VPS or a dedicated server where you owned PHP and Apache install, wizard would be likely to install the debugger and you wouldn't even bother knowing how it is done. In shared hosting where main php.ini is unavailable wizard won't get through with the install, but it will give you the precise information about what to do. Here is a screenshot of one of the last pages of the wizard:
What did we learn so far? PHP IDE told us how our windows box is seen from the GoDaddy's server (IP in debugger.hosts_allow - airbrushed for privacy concerns in the screenshot above) and which PHP Debugger's module we need to install.
Now, here is a great thing about GoDaddy's and many other shared hostings: even though you don't have access to the main php.ini file, there is a php.ini and php5.ini (for PHP versions 4 and 5 correspondingly) available to you to add php debugger instructions!
Lts get on PhpED's ssh terminal (nice feature!) and edit php5.ini in our home and these lines as suggested by the wizard, with one addition:
Note the last line:
Why port 80? Read on ...
3. Yes, now it gets tricky - here is why your shared hosting account is so dirt cheap
PHP Debugger on the server needs to communicate with PHP IDE (PhpED in this case, but the same would be the case for any other). However, GoDaddy shared hosting blocks all outgoing traffic on all ports - except for port 80! And that's what you have to use to do remote PHP debugging in GoDaddy's shared account. If you ever upgrade to VPS or dedicated server these tricks will be no longer necessary, but for now:
- Add port 80 to ports_allowed section of [dbg] in your php.ini or php5.ini
- Add your windows box IP to hosts_allow section of [dbg] in your php.ini or php5.ini - be sure to use the IP listed by dbg_wizard mentioned above, because this is the IP visible to your server! For example, it may not be the same IP that you get when running ipconfig on windows command line.
- Tell DbgListener - the communication service of PhpED to listen on port 80
- Click on the satellite dish at the right bottom corner of Windows
- Select setup in the tool bar of DbgListener dialog
- Set the port to 80
- The fact that we *must* use port 80 for remote debugging means that you need to take care to stop any services on your Windows box that might be running on port 80 - most likely that may be your local web. For example, if you are running Windows IIS you need to go to control panel->services and stop World Wide Web Publishing service and IIS Admin service. This needs to be done *before* you change the port in DbgListener to 80, otherwise DbgListener will fail to listen on that port.
- All Set! Remember one thing though - should you restart PHP Editor or edit and save PHP debugger settings in Tools->Settings->Run & Debug, this port 80 will be overwritten in DbgListener. The reason it is not what normally expected for the debugger port
4. Now the last step - start debugging session on port 80.
We found the easiest way to do it is to use DBGSESSID parameters in the url - just add this to the url of the page where you want to start debugging: DBGSESSID=blah:80;d=1,p=0,c=1
as shown below using PhpED's build it Mozilla browser:
- Dbg - PhpED's PHP Debugger will get invoked (DBGSESSID parameter in the request caused the invocation) and start talking to the client described in php.ini on port 80, as specified in the request
- DbgListener will get the request from the server and tell Php Editor to load the file and stop the execution at the first executable line (this is also controlled by PhpED settings)
- Now you can step in and look at the variables , set watches, re-assign variable's on the fly and do everything else PHP Debugger in PhpED can do. Debugging Joomla dispatch method for example:
- Note: if you have the full copy of the project locally you can edit the files on the fly and upload them on the server right away. However if the files are not copied locally the debugger will still keep on going, you'll just get a notification that you are seeing unmapped remote file, but you can still step through it
While not ideal, remote debugging of PHP applications in GoDaddy shared hosting and similar accounts is still quite possible with the tools like NuSphere's PHP Editor/IDE. Now with the introduction of NuSphere PhpED's personal edition which gives the full power of even remote debugging for under $80 dollars there is a very inexpensive solution for individual PHP developers and PHP hobbyists - GoDaddy's shared hosting for peanuts and one of the most powerful PHP IDEs on the market for not much more.
You can download NuSphere PhpED's free trial at their PHP IDE Download Page