PHP Debugging with Visual Studio Code on MacOS

2 min readJul 28, 2020

Debugging code is one of an essential thing in software developing process. Let us talk about setting up PHP debugging with Visual studio code on MacOS.


Install following items

  1. MAMP (
  2. Terminal
  3. Text editor: Visual Studio Code (
  4. Visual Studio Code’s Extension named PHP debug (
  5. Make sure you need to add this to ~/.zshrc
PHP_VERSION=`command ls /Applications/MAMP/bin/php/ | sort -n | tail -1`
export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH

First thing first, check version of php. Go to MAMP > Preferences > PHP

MAMP preference screen.

Here we go, now , we are using PHP version 7.4.2. The MAMP also provides XDebug so that you need not to install it manually.

Then add following snippets at the bottom line in php.ini

[xdebug]zend_extension="/Applications/MAMP/bin/php/php7.4.2/lib/php/extensions/no-debug-non-zts-20190902/"xdebug.remote_enable=1xdebug.remote_host=    # Not safe for production serversxdebug.remote_port=9000xdebug.remote_handler=dbgpxdebug.remote_mode=reqxdebug.remote_autostart=true

Add the snippets to php.ini for two files.


Oh wait, recheck again using phpinfo();

<?php namespace App\Controllers;class Home extends BaseController {   public function index() {
// CodeIgniter4 : app/Controllers/Home.php

It must show something like this.


Now let us start debugging. Go to Run > Start Debugging (Press F5 for Shortcut)

Debugging screen.
Break point

php.ini example snippet (

Edited by : Chutipong Roobklom