How to install XDebug on MacOS (XAMPP)

Published:

php

When you want to create codecoverage report with phpunit, you need to have XDebug installed otherwise you get just error "No code coverage driver is available". I successfully installed it on Windows but I had lot of issues installing it on MacOS.

Steps

  • check lot of websites and see that there is still new and new issue
  • prepare everything
  • clone xdebug project
  • build xdebug
  • install
  • enable xdebug module

Prepare everything

MacOS has php installed with xcode, but I needed to use newer version I am already using with XAMPP. So I just created a link to XAMPP version:

sudo ln /Applications/XAMPP/bin/php /usr/local/bin/php

In XDebug readme is, that you need to use phpize. After I linked that one, it had another problem - "fatal error: 'php.h' file not found". To solve also this problem, you have to link php-config either.

sudo ln /Applications/XAMPP/bin/phpize /usr/local/bin/phpize

sudo ln /Applications/XAMPP/bin/php-config /usr/local/bin/php-config

Clone XDebug project

You need to clone the source code, so that you are able to build it:

git clone git://github.com/xdebug/xdebug.git

Build XDebug and install it

phpize

make clean

make

make install

Enable XDebug module

The last step is to add zend_extension="xdebug.so" in the end of php.ini file. If you do not know where this file is located, just run php --ini.

Two WordPress sites with the same database titleee

When you try to use two ( or more ) WordPress sites with one shared database, you will have problem to access the pages except the original one. WordPress knows what should be its URL and when it does not match with the request, it redirects you. Fortunately, there is an easy “hack” for this to make it work.

Read more
Nice PHP console application titleee

Sometime you need to create command line interface (CLI) for your application and when you want to have it nicely formated, colorful or you want to have a table there it is not easy to do it. You can look on internet and find out, how to do such a thing, but you would have to write a lot of code.

Read more