Up until recently, I\'ve been writing code in PHP (via Notepad++) and debugging by checking the logs in IIS (gotta love that web-platform installer); I\'ve since decided to
install xdebug on your local PHP - actually update your php v with xdebug included: https://floyk.com/en/post/how-to-update-php-version-on-your-macbook-macos-sierra
setup your xdebug.ini
zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so [xdebug] xdebug.remote_enable=on xdebug.default_enable=on xdebug.remote_autostart=off xdebug.remote_port=9000 xdebug.remote_host=localhost xdebug.profiler_enable_trigger=1 xdebug.profiler_output_name=xdebug-profile-cachegrind.out-%H-%R xdebug.var_display_max_children = 128 xdebug.var_display_max_data = 512 xdebug.var_display_max_depth = 3 xdebug.remote_enable = 1 xdebug.idekey = PHPSTORM xdebug.show_error_trace = 1 xdebug.file_link_format = phpstorm://open?%f:%l
Install Xdebug helper to your Chrome browser: Install Xdebug helper
in your PhpStorm go to Settings/Preferences->Languages & Frameworks->PHP->Debug
You are done.
More detailed "step by step" guide you can find here:
https://floyk.com/en/post/how-install-php-with-xdebug-on-mac-os
I've found a more modern and easier solution partially based on CrasyCoder's post. The steps you need to do are the following:
Considering that:
Steps 1-5
are made once per php installation.
Step 6
is made once per PhpStorm project.
Steps 7-8
are made once per debuggin session.
Steps 9-11
are made each program run.
It's really simple to get Xdebug working with PhpStorm, just follow this guide carefully. (NOTE: Updated version of the guide is here)
For more advanced topics read this.
If you don't need remote debug, you can easily debug your project.
First check your php.ini settings.
Be sure that your xdebug dll exists and the settings are on.
xdebug.remote_enable = on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.show_local_vars=0
Then go to Run menu in top navbar. Then select edit configurations and add new configuration ( do not change your default settings for another project )
Click add new item button.
After adding new php web application
If you do not have any server ( generally points the localhost with 80 port on windows or linux ) click the button shown as below.
Add a new server with xdebug.
Then click ok and check your configuration
Finally, you will see the configuration at the right side of ide.
Click RUN or DEBUG button.
1. install xdebug module (MAC installation steps)
1.1.1. check what PHP version u r using php --ini
(see the loaded file)
1.1.2. brew search xdebug
1.1.3. brew install phpXX-xdebug
1.1.4. see details: php -i | grep xdebug
1.2. restart server
1.3. configuration
1.3.1. sudo find /usr -name 'xdebug.so'
1.3.2. copy the path of the exact one you need
example: /usr/local/Cellar/php56-xdebug/2.3.2/xdebug.so
1.3.3. edit the extension related configuration file which should be injected to the main php.ini automatically:
subl /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini
1.3.4. add the zend_extension
to be = the path copied above
[xdebug]
zend_extension="/usr/local/Cellar/php56-xdebug/2.3.2/xdebug.so"
Normal file should have something like this:
[xdebug]
zend_extension="/usr/local/Cellar/php56/5.6.4/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp"
xdebug.idekey=PHPSTORM
2. check your PHP version
php --ini
3. setup the IDE settings
preference > languages and framework > PHP >
3.1. set the language level to the correct PHP version of this project
3.2. set an interpreter (set the parent directory of where the bin directory of PHP executable is loaded)
3.2.1. click the … button > click the + button > other local > set PHP Excitable path,
to find the path type in the terminal: $ which php
example: /usr/local/Cellar/php56/5.6.5/bin/php
4. restart phpstorm
5. now let’s make it work
5.1. run > edit configuration > click the green + button on the left > select b. php web application
5.2. name: anything example ur {application name - debugger}
5.3. server: localhost (browse > + > name: whatever | host: localhost or 127.0.0.1)
5.4. click ok
5.5. start url: the link of ur project homepage: http://127.0.0.1:80/SomethingNew/
5.6. click ok
6. now set the break point and click debug
I had quite some troubles when I touched XDebug remote debugging the first time yesterday.
A few general hints, you are overflown with various tutorials and guides anyway.
Even following the guides, I missed several of the above points. I hope I could save some hours of struggling :)