How to initiate php-cli script xdebug session in netbeans under windows? - php

Would like to debug php cli script in netbeans under windows. All the necessary xdebug config has been done. I am sure netbeans started to support cli debugging from 6.3, am using 7.3. But it don't seems to be working. Already selected the run configuration in project properties.

Be carefull with Xdebug params, because in Windows there are two php.ini files: one for WAMP (for example) and second for PHP-CLI.
More information at:
Debugging php-cli scripts with xdebug and netbeans?

Related

How to debug PHP using VSCode IDE in Ubuntu

I need to debug PHP code using VS Code IDE. We can debug PHP using Xdebug. So I tried a lots to setup Xdebug for debugging but I failed to use Xdebug using VS Code IDE.
PHP is 8.1
Ubuntu 22.04.1 LTS
Please help me how can I debug.
Step 1:- Install PHP Debug Extension in VS Code IDE.
Step 2:- Copy Full output of Phpinfo(). run below Command in CLI for get output of phpinfo().
php -r "phpinfo();"
Step 3:- open Xdebug wizard Page & paste copied full output of phpinfo() in the form field. after the submitting form you will get step by step Instructions related to setup Xdebug in your System.
In my system currently I used Php 8.1. see below Snapshot of Xdebug Wizard Instructions.
Follow above Instruction which one you will getting from Xdebug Wizard
Note that, above Wizard Instructions is as per my server configuration. In your case it may differ than my above snapshot. So, you must need to follow Step 2 & 3.
Step 4:- add below Configuration in your php.ini file.
[xdebug]
xdebug.mode = debug
xdebug.start_with_request = yes
;Note:- Below Xdebug Path is depends on your OS & your PHP Server.
;So you need to write path of xdebug.so (in Linux)
;OR path of xdebug.dll (in windows)
zend_extension=/usr/lib/php/20210902/xdebug.so
for find Extension Directory for your server (Xampp, Lampp etc. all) then, simply Run php -r "phpinfo();" command then find out extension_dir as like below snapshot
OR write <?php phpinfo() ?> in your php file then run that php file & found out extension_dir in your output page of phpinfo.
Step 5:- Restart your Server (Apache).
Step 6:- Install Browser Extension Initiation. then start debugger in your Vs Code IDE see below snapshot.
Now, All Done.
for referece I share other source urls
refer Xdebug Docs
refer for Windows
refer this for Linux
But, before starts debugging your code, if you need to check Xdebug is working proply or not then Follow below Steps. otherwise you can ignore below steps.
In Xdebug 3+. there is xdebug_info() method exits which return info of xdebug extension.
write <?php xdebug_info(); ?> in your php file & then run this php file.you will get output as like below snapshot
& for check Xdebug works properly for CLI run php -r "xdebug_info();" in cli.

How to use Xdebug on the terminal?

I am trying to find a way to debug PHP other than var_dump() and I noticed Xdebug. I cannot find on the internet if Xdebug has a command-line version (I dont want to use a GUI version, bear with me(sshing another linux system)). If there is, how can I use it? If no, is there any other PHP debugging tools that can be run as command-line?
xdebug
Profiler:
With xdebug, you might run the profiler from CLI with this command:
php -d xdebug.profiler_enable=1 script.php
In order, to run this on the console, the box you are ssh'ing into must have PHP and Xdebug installed and configured.
Remote Xdebug:
Another option would be to use xdebug.remote_host with SSH tunneling/forwarding.
Forwarding is described here: http://derickrethans.nl/debugging-with-xdebug-and-firewalls.html
Remote Xdebugging here: http://xdebug.org/docs/remote
This allows to work with Netbeans or PHPStorm on the remote machine.
Xdebug's DebugClient
You might also use the simple DebugClient xdebug ships for CLI usage.
Every other debugging client, which supports the dbg-protocol, should work, too. http://xdebug.org/docs/install#debugclient
phpdbg
If you run PHP 5.6, then you might use phpdbg, which is the integrated debugger and perfect for CLI usage.

XDebug / Apache / PHP / Eclipse skips breakpoints

I'm having problems with XDebug.
Configuration as follows:
Windows 7 64bit
PHP 5.4.6 Thread Safe 32 bit
Apache 2.4 Thread Safe
Eclipse PDT 3.0.2
The problem is that xdebug_break() calls are not working, and breakpoints entered through Eclipse also don't function. I can see that the extension is working, as it appears as a module in phpinfo(). When I call an uncallable method, XDebug outputs the relevant error messages.
I've modified Eclipse's web server path mapping, to no avail.
Here is my php.ini config:
zend_extension = c:/php/php_xdebug-2.2.1-5.4-vc9.dll
xdebug.remote_enable = 1
xdebug.remote_host = localhost
xdebug.remote_port = 8080
xdebug.remote_mode = req
Any help would be kindly appreciated...
First check that what version you are using of PHP in eclipse....
Check it through:
Window->preference->PHP->PHP Interpreter....
Version there should match with the PHP version.....
Reply if problem is not solved....
For all those, that are still fighting with this problem, some handy tips.
Check which version (package) of Eclipse you have? It turns out, that Helios package has some bugs and doesn't stops on breakpoints, when you debug your application as Web Application. Debugging works only, if you run it as PHP Script. Which makes it pretty useless for debugging process.
You should consider either reverting to older Galileo Package Eclipse for PHP Developers or installing newest Eclipse Juno (or even newest developer version of Eclipse Kepler), which doesn't have PDT support build in, but you can easily add it to then, using Help > Install New Software.. (point it to http://download.eclipse.org/tools/pdt/updates/release).
These versions are reported to be able to debug as Web Application, respecting breakpoints.
Also, remember, that Xdebug must be run as Zend Extension in order to support breakpoints! In other words remove extension=xdebug.so (on Linux or xdebug.dll on Windows) line from your php.ini and replace it with zend_extension=/full/path/to/xdebug.so (on Linux or zend_extension=X:\full\path\to\xdebug.dll on Windows). Zend extensions requires full path, even if they're put into /php/ext folder, as regular PHP extensions. You'll find more info on this in Xdebug FAQ (look for an answer to "Xdebug is only loaded as PHP extension and not as a Zend Extension" question).

No output trying to use Selenium with PhpUnit and Yii on wampserver on XpPro without Netbeans

I'm working my way through Agile-Web-Application-Development-with-Yii11-and-PHP5.
I've installed PhpUnit and Selenium and started the Selenium server from a command line and left it running.
I found a simple script to run and confirm that Selenium server is running.
When I run the functional\SiteTest.php file I get no output and SiteTest.php is opened in Netbeans, my default application for php files.
Many thanks.
Gregory.
I have experienced the same situation on windows in the following way:
Behind the scene there's an error but the php.ini hided it.
I've changed the display_errors = Off to display_errors = On in the php.ini.
Running again the functional test I've discovered that the error was in the line 11 of
the class CWebTestCase.php (require_once('PHPUnit/Extensions/SeleniumTestCase.php')) due
to Selenium extension missing on my pc.
You can verify it's missing (or not) looking at PEAR\PHPUnit\Extensions directory
I have downloaded the extension with: pear install phpunit/PHPUnit_Selenium
I've revert the 2. update (again to Off).
I've run the phpunit functional/SiteTest.php and it works!
Enrico
You probably need to run the file in a terminal window with the phpunit command:
phpunit functional\SiteTest.php

how can i associate/use PDT with eclipse in ubuntu?terr

I want to use PDT to debug PHP with eclipse. I am using ubuntu 9.04.
Can any one help me? please give details if possible.
Considering this thread and this one:
You have to ensure that xdebug is definitely loaded on the version of php you are using.
To do this, use the launch configuration you are using to try to run your script in debug mode and change it to run a script with phpinfo.php in it.
Also a Debug log would be good.
Add:
xdebug.remote_autostart=On
xdebug.remote_log="c:\temp\xdebug.log"
to your php.ini.
Then you have to insure that PDT is expecting Xdebug information on port 9000,
and have insured that your local Default PHP Web Server is http://127.0.0.1.
With the log, you might discover, for instance, that your php.ini files is not properly formatted, which could be enough to prevent you debugging PHP from PDT.
UYu would have to install PHP5 xdebug extension first,
sudo aptitude install php5-xdebug
after you would have to check your settings by editing /etc/php5/conf.d/xdebug
after you have to setup your php project to use xdebug and you should be done.
I'm use PDT in Ubuntu 9.04 and can fine debug my php projects.
first as already answered install php5-xdebug through apt-get or synaptic (I'm think you already install php5 itself in same way :) ). Then you must define php executables in Window/Preferenses/PHP/PHP Executables. You can point to /usr/bin/php, or can use 'Search...' button, but you must point initial search dir to nearest to your php exec binary. After found executable it always set to use Zend Debug by default. Edit executable to change 'PHP debugger' type to XDebug. And now a main trick. When you try debug your php scripts without create run configuration - it will always use Zend Debugger. You must create your own run configuration with XDebug setted as PHP Debugger. It's worked for me.

Categories