Buying Advice. How-Tos. Photos. Thoughts.

If it did not work, please make sure that you really copied over the xdebug. Before we can actually start debugging, we need to enable Xdebug. Therefore, I hope you didn't close out your php. Save and close your php. Your values should look exactly like mine:. Now, open your IDE of choice. Now choose your personal IDE key. This can be any alphanumeric string you want. It is important to set the "Port" value to as our standard Xdebug configuration uses this port to connect to the IDE. Tip: If you need to adjust this, add xdebug. Attention: Other components may change this value inside of PhpStorm, so watch out for it if something fails.

Next, click that red little phone button with a tiny bug next to it on the top toolbar. It should turn green. This makes PhpStorm listen for any incoming Xdebug connections. Now we need to create something to debug.


  • xdebug with XAMPP on Mac OS X.
  • 1. Install xdebug;
  • Installing PHP 7 with XDebug, Apache and MySQL on OS X Yosemite.

Create a new PHP file, call it whatever you'd like and paste in the following code:. Make sure everything is saved and open up your browser to the script we just created. I will use Google Chrome for this demo, but any browser will do. Now let's take a moment to understand how the debugging process is initialized.

Our current status is: Xdebug enabled as Zend extension, listening on port for a cookie to appear during a request. As Xdebug sees the cookie carrying the request, it will try to connect to a proxy, our IDE. So how do we get that cookie in place? PHP's setcookie? Although there are multiple ways, even some to get this working without a cookie, we will use a little browser extension as a helper.

Xdebug - Professional PHP Debugging

Install the "Xdebug helper"" to your Google Chrome browser or search for any extension that will do it for the browser you are using. Once you've installed the extension, right click the little bug appearing in your address bar and go to the options. After configuring it, click the bug and select "Debug" from the list.

The bug should turn green:. Breakpoints are like markers on a line which tell the debugger to halt the execution of the script at that breakpoint. In PhpStorm, you can simply add breakpoints by clicking the space next to the line numbers on the left hand side:. Just try to click where the red dot appears on the screenshot.

You will then have a breakpoint set at which your script should pause. Now we are all set. Go back to your browser, make sure the bug is green and just reload the page to submit the cookie with the next request. If everything goes according to plan, this window should pop up inside of PhpStorm to inform you of an incoming debug connection:. Did the window not popup for you?

How to Install XDebug on a new Mac (including Mojave) | Devin Baldwin

Let's do some troubleshooting and repeat what needs to be set in order for this to succeed:. If you get the dialog seen on the previous image, please accept it. This will take you into debug mode, like so:. You can see that the debugger stopped the script's execution at your breakpoint, highlighting the line in blue.

PHP is now waiting and controlled by Xdebug, which is being steered by your very own hands from now on. Our main workspace will be the lower section of the IDE which is already showing some information about the running script the superglobals. And would you look at that? There's the cookie we just set to start the debugging session. You can now click through the superglobals and inspect their values at this very moment. PHP is waiting, there is no time limit, at least not the default 30 seconds.

On the left side, you'll see a few buttons. For now, only "Play" and "Stop" are of interest to us. The green play button will resume the script. If there is another breakpoint in the code, the script will continue until it reaches the breakpoint and halt again. The red stop button aborts the script. Just like PHP's exit or die would do. Start stepping over the code, statement by statement. Note that the blue line only halts on lines which actually contain a command. Whitespace and comments will be skipped. Once you reach the function call to loadData , please do not step into it , just step over and halt on the if statement.

You can see two new variables in the "Variables" panel on the bottom of the screen. It seems like the script should have done its job.

1) Download the source file

Let's take a look. We get a message informing us that we can not "step back". In order to get your debugger to line seven again, you need to stop this session and reload the page in the browser. Do so and step into the function call this time. Stop on the return statement inside of the loadData function and see what happened:. The return statement uses a ternary operator to detect what to return.

And it will return false for an empty array. Now stop the debug session, reload your browser, and step over the function call this time. Now it seems like we still have a problem as we step into the condition. Now it's up to you to try and step around a bit. I would suggest to revert the script to the original falsy version, debug it with echo 's and then compare how that feels in comparison to using Xdebug. Throughout this article you should have gained a lot of new knowledge.

Don't hesitate to read it again and to help a friend set up Xdebug - nothing better than that! You may want to try replacing your usual debug behavior by using Xdebug instead. Especially with larger, object-oriented projects, as they become much easier to debug and even catch up on the flow, if you don't get something right away. Note that this is just the tip of the iceberg. I pass this tip along in case it helps someone else:. When editing the php. Notice I have two lines of comments reminding me what I did and when. The way the php. They are not and so the lines following are not read.

PhoneGap Mac OSX Development Environment Setup (for Android debug)

When you run phpinfo you will see that xdebug is not being loaded and you may be left wondering why. No error is given unless you run something like: php -v from the command line in terminal. When you have an error in your php. Check to see if you left out a ";". Once you finish editing, be sure to restart the Apache webserver. I had an issue when installing pear, but it worked using this couple of lines instead of the one you provided:.

Thanks for your tutorial. Sad to say it did not work for me straightaway on a fresh install of Mac OS X However, when I added these steps it works just fine:. Good tutorial. Blog Where we discuss our work, thoughts, and process. This is the easy part. Related Posts.

Precompiled Windows Modules

Oct 17, Aug 29, Like This? Share it! Email Newsletter Our monthly highlights. Matt Hi Josh, I followed your instruction, and tried many variations found around the web as well, but nothing seems to work in loading xdebug with my php installation. J Alexander Josh, thanks!