Debugging PHP applications with PhpStorm
Friday, February 21. 2014
Anybody who has reached a certain level of skill in software development eventually will start thinking about how to make the job easier or be more productive during the day. With computers and programming, the tools you're using is a good starting point.
I've written code with a number of text editors (including vim and notepad), some of them really bad and some of them more suited to the task at hand. IMHO one of the best editors for a software developer is Microsoft's Visual Studio. Since many of my projects involve PHP, that is not the optimal editor for that. For years I used Notepad++, but then I got a recommendation for JetBrains PhpStorm. Since that it has become my weapon of choice for PHP.
For example, debugging the application is very simple operation. PhpStorm has all the client-stuff built into it, the only thing that is needed is Xdebug-extension to the server end. In my case, my web server is on a Linux and I typically work on a Windows 7. The debugging is done over my LAN. There is a very good article on PhpStorm author's web site with name Zero-configuration Web Application Debugging with Xdebug and PhpStorm. I don't think the zero-configuration part is true, but it is almost zero anyway.
On the server end I have a PHP-fpm running, it has
php_admin_flag[xdebug.remote_enable] = on
php_admin_value[xdebug.remote_host] = my_machine_name
php_admin_value[xdebug.remote_port] = 9000
In the worker configuration. That enables the server side to initiate a DBGP-connection to the given client (PhpStorm) and start sending data there. There reference for all the configuration directives can be found from Xdebug's docs.
On the PhpStorm end all you have to do, is enable the listener:
Also I had to drill a hole into my Windows 7 firewall, to allow my web server to connect into TCP/9000. If you're running a single machine setup, that won't be necessary.
Any settings for the setup can be found in the PhpStorm project:
But I think they're ok as a default. At least I didn't change anything there. If your debugger does not work, you fumbled the settings or your listener is not enabled. On Windows, run this on command prompt to confirm:
PS J:\> netstat -ano
Active Connections
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:9000 0.0.0.0:0 LISTENING ?
It will return a long list of things, but one of the entries must be similar to that.
To make the choice between debugging and not debugging can be made really easy. There are a number of ways of starting a debug session, but for Firefox users there is an excellent add-on The easiest Xdebug. It will add an icon to your add-on bar:
If the bug is green, it will send a special cookie to the server during a page load request:
Cookie: XDEBUG_SESSION=netbeans-xdebug
That will initiate the debugging session for you and PhpStorm will stop on a breakpoint if one is set.
Switching to PhpStorm vastly improved my productivity. I would imagaine, that it will do that for anybody.
Robin on :
For Google Chrome you have the "xDebug helper" (here: https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en)
Chrome also has the extension Postman, which installs on your pc as an application, allowing you to send requests (GET/POST/PUT/UPDATE/etc) (here: https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en).
For FireFox you have the same as you mentioned (The Easiest xDebug).
Debugging, once enabled in PhpStorm can also be enabled manually (this method is required to debug with Postman) by adding this to the URL: ?XDEBUG_SESSION_START=PHPSTORM
Note that on Windows systems xDebug might not be installed with the localhost server (such as Xampp). You can then install the required .dll file following instructions here https://xdebug.org/download.php. That page also has a link called "custom installation instructions" where you can paste your entire phpinfo() information, it will return you the version of xdebug to install and where to copy & paste the .dll file to.
Stas on :
kay on :
fonepaw android data recovery crack on :
I'm sure they will find this site useful.
Jari Turkia on :
I'm glad your friends found my stuff useful. Hopefully you'll do the same even with your advertisement removed.
Jari Turkia on :
Also you're welcome not to advertise your product here.
sana on :
vso-downloader-ultimate-crack-serial-key-free
ApowerUnlock Crack
Thunderbird Crack
Balabolka Crack
ProfiCAD Crack
Jari Turkia on :
I had to admit, I removed the name of your website to make your advertising little bit less effective and to flick you my middle finger.
Crack2Key.Org on :
sana on :
I am using my laptop for almost the past 2 years, but I had no idea of solving some basic issues.
I do not know how to Free Download But thankfully, I recently visited a website named
-site-removed-