Now. Installation.
If you want to download and compile xdebug from source, walk away now. I installed the binary directly.
The best way to install it on a redhat or sister systems (e.g. CentOS) is to use pecl. Run the following to see if you have it on your system:
which pecl
If not installed, sudo yum install php-pear , pecl is included in this package.
I then ran
sudo pecl install xdebug
This might work for you. But in my case it failed cos it cannot find phpize. If this happens to you, install php-devel.
sudo yum install php-devel
Also, on one server, pear was configured to use an invalid proxy. Because of that, pecl cannot find xdebug. To resolve this issue, run this to list the configurations:
pear config-show
Then unset the proxy:
pear config-set http_proxy ""
You can now check if pecl can find xdebug:
pecl search xdebug
After this, you can try install xdebug again and it should pass. Have a look at the output in the terminal, you need to make use of the installation path.
Next is to edit the /etc/php.ini to include a line like this, use the path you have noted down:
zend_extension=<your/path/to>/xdebug.so
I also added the following lines for xdebug:
xdebug.remote_enable=1
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_mode=req
xdebug.profiler_enable = 1
xdebug.scream=1
xdebug.profiler_output_dir = "/tmp"
All the guide I saw stopped here, sort of. I then tested it out, just to find it not working. What I did not realise is that the pecl install does not set correct permissions. Now chmod to your xdebug.so, set it to
-rwxr-xr-x. 1 root root 787575 Jul 26 18:07 xdebug.so
It now should be OK.
But still, we need to test.
Here is something I found on the net: create a file, say, test.php,
<?php
function test(){
echo "Called @ ".xdebug_call_file().
":".xdebug_call_line()." from".
xdebug_call_function();
}
test();
?>
cd to that directory,
php test.php
you should see something like: Called @ /var/www/html/test/index.php:13 from{main}
You see this, you are all set. Otherwise check you configuration. In my case, when I copy paste in the line in php.ini, I missed the leading character. That took me a while to find out...
NetBeans needs a bit configuration, too. The main guide can be found in the netbeans official tutorial. There is one further tweaking to do:
Just below the top menu bar, you will see a drop-down list, which defaults to <default>. Click on it, choose Customise.
Wala, now you see the project properties. Project URL, Index file, Arguments are the useful ones to know at this stage. You will need to control which page you want to start with.
I like to use Codelobser IDE woth xDebug.
ReplyDelete