Working as of 2021

As homebrew removed the extra php repository containing a version with xdebug already installed, you have to install it manually.

Summary:

  1. brew install <php version> for php
  2. update your path
  3. sudo pecl install xdebug for xdebug

Full example:

# update homebrew
brew update

# install a version of php, e.g. 7.0
brew install php@7.0

# now they tell you how to link it, in my case
echo 'export PATH="/usr/local/opt/php@7.0/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.0/sbin:$PATH"' >> ~/.bash_profile

# reload the file with the updated path, so we can use pecl
source ~/.bash_profile

# check that the path is to the correct php executable,
# and pecl is available
which pecl
# returns: /usr/local/opt/php@7.0/bin/pecl

# install xdebug, see https://xdebug.org/docs/install#pecl
pecl install xdebug

# check that everything worked
php --version
# should show a xdebug version
# like: with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

The sudo pecl install xdebug step above ended with

Build process completed successfully
Installing '/usr/local/Cellar/php@7.0/7.0.30/pecl/20151012/xdebug.so'
install ok: channel://pecl.php.net/xdebug-2.6.0
Extension xdebug enabled in php.ini

So I didn't even need to enable the xdebug.so in php.ini.

If you need a special version of xdebug (e.g. your IDE doesn't like the 3.x.x versions), you can install a specific version xdebug-$VERSION, e.g. pecl install xdebug-2.9.8. You can find them on the list of available versions (Thanks Bower)

References: https://stackoverflow.com/questions/12712017/cant-install-xdebug-on-mac-with-homebrew

--

--

--

Currently work as Coder since 2011 and still have to learn. Dota 2 and Football Manager are the games I still play to stay fresh.

Love podcasts or audiobooks? Learn on the go with our new app.

Summer Research Initiative Week 4

How to build an API endpoint with Node.js, AWS Lambda and AWS RDS PostgreSQL DB [Part 3]

Monthly update — July 2019

How to download YouTube Videos & YouTube playlist using python3 ?

Modern Application Security — What are Modern Applications?

Build and deploy a WebJob alongside web app using azure pipelines

Hackathons: What They Are and How to Join

Phase 1 — Shield Strength

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Budiaramdhan Rindi

Budiaramdhan Rindi

Currently work as Coder since 2011 and still have to learn. Dota 2 and Football Manager are the games I still play to stay fresh.

More from Medium

How I set up a new Mac in minutes with a simple Homebrew script

10 Important Tips to Keep in Mind When Choosing a PHP Framework

Convert a local development folder into a Git repository

How to Solve Spatie/laravel-sitemap installation issue