Created
November 8, 2013 15:47
-
-
Save TonyWael/7372954 to your computer and use it in GitHub Desktop.
Xdebug php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to run Xdebug on Mac OSX using MAMP | |
1 Start MAMP | |
2 Edit php.ini template file through MAMP to enable the extension. Edit the template file via File -> Edit Template -> PHP -> PHP [php version you are using] php.ini | |
edit php.ini template for mamp on mac osx | |
3 Edit bottom of php.ini template file so that it ends up looking like if you want profile output | |
[xdebug] | |
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so" | |
xdebug.profiler_enable = 1 | |
xdebug.profiler_output_dir = "/tmp" | |
; DONT REMOVE: MAMP PRO php5.3.6.ini template compatibility version: 1 | |
If you don’t want profile output and just want xdebug running then use | |
[xdebug] | |
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so" | |
xdebug.profiler_enable = 0 | |
xdebug.profiler_output_dir = "/tmp" | |
; DONT REMOVE: MAMP PRO php5.3.6.ini template compatibility version: 1 | |
Now when you have errors, if they are sent to standard out, you will see something like this | |
Debugging CodeIgniter Project using Xdebug and Netbeans | |
12 | |
FEB | |
Finding the right way to debug PHP projects has always been a hot topic. Primitive solutions like `echo`, `print_r`,`var_dump` has always been the power tool :) for my type of ppl . Let us forget those painful nights and go to a quick debugging solution with Xdebug and Netbeans 6.8; in a 1-2-3 step guide for CodeIgniter. | |
What i am expecting from you: | |
You already have a running web server [ Xampp/WAMP/ Uniform server ] | |
You know how to install Netbeans IDE 6.8 or it’s already running in your environment | |
You know what is CodeIgniter | |
You are not a complete Newbie | |
# STEP – 1 | |
First add extension Xdebug in PHP. Download latest stable Xdebug version from Xdebug.org. Follow the procedures. If you are lazy like me and don’t want to read the whole thing [it's a bad habit :) ] copy the following settings and put at the end of your php.ini by not forgetting to change the path :) | |
zend_extension_ts="C:/wamp/bin/php/php5.2.9-1/ext/php_xdebug-2.0.4-5.2.8.dll" | |
xdebug.remote_enable=on | |
xdebug.remote_handler=dbgp | |
xdebug.remote_host=localhost | |
xdebug.remote_port=9000 | |
Note: If anything messes up later; come back and study those links over and over till u understand the whole thing. | |
# STEP – 2 | |
Configure CodeIgniter to accept ‘?XDEBUG_SESSION_START=netbeans-xdebug’. You can follow one of my post or check in codeigniter forums for accepting GET data in CodeIgniter. | |
Start Netbeans IDE. Goto Tools >> Options >> PHP >> General: and check for settings in Debugging section. By default the port should be 9000 and Session-ID ‘netbeans-xdebug’. | |
#STEP -3 [ FINAL :D ] | |
Let’s say, You have installed a ‘test’ CodeIgniter application in your web server. Now add that application as a project in Netbeans 6.8 . Goto Project properties by right clicking on the project ‘test’. Now go to ‘Run Configuration’ and click ‘advanced’ select ‘Ask Every time’ in Debug URL. | |
Now Open your ‘welcome’ controller and press ‘Ctrl+F5′ which will request for the URL: | |
specify url | |
insert ‘http://localhost/test/’ and press ‘Ok’. Next select `Server side PHP`. | |
Clicking in ‘Debug’ button will open ‘http://localhost/test/?XDEBUG_SESSION_START=netbeans-xdebug‘ In you default web browser. | |
Now check in status bar for: | |
And check in toolbar for: | |
If those 2 shows up then u have successfully installed Xdebug+Netbeans. Your IDE is ready to do some debugging. Take your cursor over a line on index function of welcome.php; press ‘F4′ this will execute php scripts till that cursor. Dont worry if index.php is opened up focusing on first line. | |
Now You can watch for variables or step into functions or step over. You can check your code line by line. | |
Read this link which have brief discussion on what options you have for Debugging :) . | |
My counting on steps could be wrong :) .. bt it looks nice 1-2-3. I tried not to explain a lot; so for more details study provided links. I hope this will make your life more easier. Enjoy !! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment