XDebug - PHPStorm - Mac: How to configure Xdebug with PHPStorm on Mac OS and PHP 7.3

For this illustration we are using PHP7.3 Find the path of your PHP ini files by opening the console and running following command:
php --ini

In your root folder create a new file using following command and generate Phpinfo file:
sudo vi phpinfo.php


Now in your browser run: http://localhost/phpinfo.php . Copy the entire output from this page and paste it into https://xdebug.org/wizard This will give you the download link to xdebug. Now open your console and run below commands:

Check the path against "Scan the additional .ini files in". In most cases the path would look something like "/usr/local/etc/php/7.3/conf.d"

sudo vi /usr/local/etc/php/7.3/conf.d/ext-xdebug.ini



Now in your PHPStorm perform below steps:
  • Click on PHPStorm > Preferences > Languages & Frameworks > PHP > Debug
  • Under Xdebug > Change "Debug Port" to "9001" and select "Can accept external connections
  • Click on Apply


You can validate your Xdebug installation with PHP using below steps:

You can validate your Xdebug settings for PHPStorm with below steps:
  • Navigate to PHPStorm > Preferences > Languages & Frameworks > PHP > Debug
  • Under Pre-Configuration > Click on Validate debugger configuration on the Web Server
  • Select Local Web Server or Shared Folder
  • Under "Path to create validation script" add path to your Project's Root Directory
  • Under "URL to validation script" add your localhost URL or URL to your project home-page
  • Click on Validate


In order to run Xdebug do following settings in your PHPStorm:
  • Navigate to PHPStorm > Run > Edit Configurations
  • Click on "+" symbol at top left of the window and select "PHP Remote Debug" from the drop-down list
  • In the right-hand pane add the name of your Xdebug profile. For example "My Remote Debug"
  • In the right-hand pane Under configuration tab select "Filter debug connection by IDE Key"
  • Click on "..." near Server and add your project settings (Name: Project Name, Host: Your project's localhost URL - example.local, Port: 80, Debugger: Xdebug) and click on Apply
  • Add "PHPSTORM" against IDE key(sessiod id)
  • Click on Apply
Your Xdebug is now ready to use. Place a breakpoint in your codebase and run the host URL in your browser, it will stop at the breakpoint. Picture Source: pexels.com

Comments

Popular posts from this blog

Elastic Search - How to install and manage multiple versions of elastic search