Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup XDebug for PHP7 on Mac?

I've installed PHP 7 on my mac using Homebrew i.e.

$ brew install php70

Also I want to have the the XDebug setup on my machine.

Ideally I would love to have an easy solution like using brew again, but unfortunately it seems there is no such formula exist (at least yet), and the latest package is homebrew/php/php56-xdebug.

I thought before start the manual installation, check here to see if there are any other workaround.

Any advice will be greatly appreciated.

like image 554
Ali Avatar asked Aug 29 '15 22:08

Ali


People also ask

How do I install Xdebug for PHP7 on Ubuntu?

To install Xdebug for PHP7 on Ubuntu you will need to do so manually. Ubuntu 15 and lower will not come with a package for PHP7 or its xDebug counterpart. First, be sure you are using PHP 7 already by checking your version. PHP 7.0.0-2+deb.sury.org~trusty+1 (cli) ( NTS ) Copyright (c) 1997-2015 The PHP Group ...

Why is Xdebug not showing up in PHP?

If Xdebug does not show up, or you get a warning from PHP that an xdebug.so file or similar was not found, you might need to use the full path instead of just zend_extension=xdebug, such as zend_extension=/usr/lib/php/20190902/xdebug.so.

How do I enable Xdebug in PECL?

You can check your version using php -v. Then, run pecl install xdebug. Once it's finished installing, you'll see a message like this: Then go to your php.ini (which you can find by running php --ini, and add these two lines to it: Obviously, change the path to whatever was printed by the pecl xdebug installation.

Where can I download the source code for Xdebug on macOS?

We’ll assume that you have already installed PHP Tools for your macOS, but if you haven’t, you’ll find a tutorial right here. Xdebug can be found on its webpage and it’s also hosted on Github. The source code can be downloaded from both locations. For this tutorial, we have downloaded it directly from the Xdebug page here.


Video Answer


2 Answers

First, make sure you're on the version of PHP for which you want Xdebug installed. It needs to be installed separately for each major version (7.0 vs 7.1 vs 7.2). You can check your version using php -v.

Then, run pecl install xdebug.

Once it's finished installing, you'll see a message like this:

Installing '/usr/local/Cellar/php/7.2.8/pecl/20170718/xdebug.so'

Then go to your php.ini (which you can find by running php --ini, and add these two lines to it:

zend_extension="/usr/local/Cellar/php/7.2.8/pecl/20170718/xdebug.so"
xdebug.remote_enable=on

Obviously, change the path to whatever was printed by the pecl xdebug installation.

like image 90
Sam Malayek Avatar answered Dec 15 '22 01:12

Sam Malayek


As stated by Homebrew, Homebrew/php tag was deprecated.

So it's not possible to install xdebug through Homebrew anymore. Please use PECL instead: https://xdebug.org/docs/install#pecl

like image 33
Tony Xu Avatar answered Dec 15 '22 01:12

Tony Xu