Note: This post focuses on developing a Drupal website on a MacOS machine using MAMP & MAMP Pro hosting software, Apache HTTP Server, and MySQL Backend. The goal is to debug the PHP file to access the variables available in a Twig template.
Turning on X-Debug for PHP (Pro MAMP)
If you are developing using a Pro MAMP: simply turn the the “Xdebug (Debugger)” setting under the “Language > PHP” tab (on the sidebar):
Then click “Save”, and start/restart MAMP, and proceed to phpinfo page for mamp, and scroll down; At the roughly middle of the phpinfo page, you should be seeing something like this (link to image of full xdebug):
Turning on X-Debug for PHP (Non-Pro MAMP)
If you are developing using a non-pro MAMP software: first turn the MAMP off, then configure the php.ini
file located at the directories (noting that when you change to a different php version, you will have to repeat the step, adding the lines in to the corresponding php.ini for the selected version):
/Applications/MAMP/conf/php[version]/php.ini
/Applications/MAMP/bin/php/php[version]/conf/php.ini
At the bottom of the file, you will see something like:
|
|
In order to turn on the xdebug extension for php, simply uncomment the line for zend_extension
:
|
|
Or, if you wish to make further customization to the xdebug, here’s an example configuration to quickly copy from:
|
|
Then start/restart MAMP, and proceed to phpinfo page for mamp, and scroll down; At the roughly middle of the phpinfo page, you should be seeing something like this (link to image of full xdebug):
In case this is not working, try confirming you are changing the right configuration file (also via phpinfo)