xdebug, sublime-text-2 and KindariSublimeXdebug - php

I have never used Xdebug, but i would like to start. I am using Ubuntu Linux and have already been able to:
install php5-xdebug and make sure it is working
through phpinfo() and var_dump()
install the plugin through Sublime's Package Manager
I can access the plugin's menu through SHIFT+F8 setup the Xdebug url
in sublime settings:
"settings": {
"xdebug": { "url": "http://your.web.server" }
}
Here's what is going wrong:
I can place breakpoints in the code, but the icon seems to be wrong,
it's just an orange blob
When I "start debugging" the debug window appears completely empty
when I access my script, it doesn't stop at my break points.
What am I doing wrong?

these are the whole steps, worked for me
sudo -i
apt-get install php5-xdebug
vim /etc/php5/conf.d/xdebug.ini
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
:wq
apachectl restart
exit
Download do SublimeXdebug
unzip
move folder para ~/.config/sublime-text-2/Packages/Xdebug
Download python 2.6 (careful with i386 vs amd64)
dpkg-deb -x python2.6_2xxxx.deb python2.6
move folder to ~/sublime/lib/python2.6
open google chrome
chrome://settings/extensions
Get more extensions
search for xdebug
install xdebug helper
go to "options" of xdebug helper
in IDE type "other" and in input "sublime.xdebug"
start sublime
open file test.php
add breakpoints
start debugging
in chrome go to http://localhost/test.php
activate the icon of the plugin
refresh
That is it!

Here is a very cool tool from Jetbrains, the makers of phpStorm:
http://www.jetbrains.com/phpstorm/marklets/index.html
Basically, just enter in the IDE key for your xdebug (or zend debugger if that's your thing) IDE and it will create bookmarklets to connect and enable the various functions.
For sublime text 2, the IDE key is:
sublime.xdebug
When you use the bookmarklets, you don't need enter in any server information on either end. Just "Start Debugger" on each and everything should work itself out, as long as you've left the default settings.
You still need to enable xdebug on your server of course.

You can enable xdebug log to debug xdebug.

I had a similar problem (I am running on Windows 7 though) and what worked for me was just making sure that I ran Sublime Text 2 as a Windows administrator. I believe this makes sense, since xDebug is a third-party dll to the system.
Maybe running sublime as a super user (using SUDO) might help in your case.
Hopefully this solves your problem.

Does your sublime also fail to save project settings, like the recent project list?
I had the same issue, you can see it here:
https://github.com/Kindari/SublimeXdebug/issues/69
The solution was to delete / move the ~/.config/sublime-text-2 folder then start again with a fresh sublime. After that, breakpoints looked normal and my debugger would connect :)

Related

PHP Xdebug Laravel application in IntelliJ IDEA

Could you please advice me how properly configure Xdebug for Laravel application. I found a lot instructions for PhpStorm but they do not work for me as I'm using IntelliJ IDEA Ultimate.
What I have already achieved - I can debug single PHP script but not whole application. I cannot follow completely the instruction which is given for PhpStorm because on step when I need to configure Run/Debug Configuration I got stucked.
Much appreciation on any help in advance!
Okay, I gathered full instruction how to work with XDebug and IntelliJ Idea Ultimate to debug Laravel application and Windows specifically (if you use other OS the installation part will be different but other should be the same):
First of all you need to install XDebug itself and configure PHP to work with it. For that:
Find out which PHP version you use using phpinfo() you will need Version, Architecture and PHP Extension Build sections to complete next step.
Go to https://xdebug.org/download.php and download appropriate build. Basically it is dll provided for specific PHP you have installed
After that copy that DLL to Apache modules directory - for me that is D:\OSPanel\modules\http\Apache-PHP-7-x64\modules\ as I'm using OpenServer.
Put into php.ini file following configuration:
[Xdebug]
zend_extension="D:\OSPanel\modules\http\Apache-PHP-7-x64\modules\php_xdebug-2.6.0-7.1-vc14-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_host = "localhost"
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_port=9000
xdebug.idekey="PHPSTORM"
where php_xdebug-2.6.0-7.1-vc14-x86_64.dll is name of dll I personally downloaded.
Restart Apache
Open your Laravel project and check your Debuggin configuration (File > Settings... > Languages & Frameworks > PHP > Debug): check XDebug section if Debug port is the same as you specified above (it should be, if you did not changet it previously)
Delete all your Run/Debug configurations
Install Xdebug Helper for Chrome or any other extension if your not using Chrome (Browser Debugging Extensions)
Hit Run > Start listening for PHP Debug Connections
Put break point in your project and open appropriate site context
Enjoy!
Hope that will be useful for community.

Using xdebug with PhpStorm

I can't get my PhpStorm IDE to work with xdebug.
My current setup is the following:
PhpStorm 2017.1.4
MacOS Sierra 10.12.5
Here are the steps that I followed.
I have installed php with the following command. I have added the postgres parameter because I need it later to connect to a PostgreSQL database.
brew install php71 --with-postgresql
The next step is to install XDebug with the following command
brew install php71-xdebug
So the next step that I got from the documentation (https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html) is to edit the php.ini file with the following content:
[Xdebug]
zend_extension="<path to php_xdebug.dll>"
xdebug.remote_enable=1
xdebug.remote_port="<the port for Xdebug to listen to>" (the default port is 9000)
xdebug.profiler_enable=1
xdebug.profiler_output_dir="<AMP home\tmp>"
Just some questions about those fields and XDebug.
So I guess XDebug is some kind of service that runs on the remote_port and that PhpStorm is using to write data to? Or do you have to specify the port where the application you want to test is running?
What exactly is the profiler thing? And can the output dir be anything I can choose?
So this is my php.ini file that I think it should be:
[xdebug]
zend_extension="/usr/local/Cellar/php71-xdebug/2.5.4/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/usr/tmp"
That's it for the php.ini. So I have to check the settings in my PhpStorm IDE. And those are the following:
So that is my setup. In my project I just have one index.php with <?php echo phpinfo(); ?> I just click the Chrome icon so it opens directly in the browser to check if XDebug is there. I see the following result.
So I thought to myself ok let's try some debugging. So I changed my index.php file to the following
$i = 2;
$j = $i + 2;
echo $j
I've put a breakpoint on the 2nd line. And when I run it, it never stops at the breakpoint. What is needed to do that or am I wrong in my configuration somewhere?
To make Xdebug remote debugging working on your page, you need to set a cookie in your browser, telling the server you want to debug the page, there are many extensions for that, the most known is Xdebug helper in Chrome.
I also suggest you to follow this tutorial Zero-configuration debugging, it is very detailed and clear IMO.
If you still have problems i'll try to help you with pleasure :)

php debugging on a Mac?

I've seen these answers: debugging php on mac?
but I am hoping that there is a better/newer solution. I am a system-level developer (C/C++/x86) but totally new to the web/scripting space. I feel that I would do well do setup a solid debugging environment - it is usually a great way for me to learn.
Any suggestions/pointers as to a good php debugging setup on a Mac (10.6) would be much appreciated.
Thanks,
Matt
I'm a Mac user myself and since I do some heavy PHP development, I need an elaborate setup for this.
First of all, the standard PHP and Apache installed in Snow Leopard isn't bad, but upgrading or adding extensions to it is quite a task. To be able to fully control the environment, I decided to install the entire AMP stack using MacPorts. Don't worry about overwriting existing files, as everything will be installed in separate locations. Just make sure you disable the stock Apache before starting the newly installed one. There are loads of tutorials on how to get this done.
My IDE of choice is Komodo IDE. This IDE comes out of the box with integrated debugging using a preconfigured xdebug setup. I have ended up compiling and using the latest xdebug version instead of the stock version for compatibility reasons (PHP 5.3+). Many developers use the aforementioned Eclipse + PDT which offers a similar IDE, although slightly more has to be done to get it configured properly.
For remote debugging I have configured the PHP module in apache to load xdebug also and connect to my running IDE. More info about that can be found here. For complex web applications it is ideal if you can just open the browser, navigate to the correct webpage and activate debugging to step into the first line of code of that page.
For performance testing and tuning I use the profiling feature of xdebug. When enabled, xdebug will write callgrind files to a specific directory. I use MacCallGrind to visually analyse the profiler files. There is a free alternative called KCacheGrind which can be installed if you enabled MacPorts (as mentioned in the first suggestion).
I use this environment to develop pretty complex and large multi-homed projects, involving commandline (daemonized) PHP applications that utilize forking and IPC structures and extensions like memcache. I'm quite satisfied with how this setup works for me.
There is a way how to do it using:
PhpStorm
Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Php + Xdebug
1) Install php and debug
brew install php70
brew install php70-xdebug
In PhpStorm - check Preferences => Language and Frameworks => PHP
Php language level: 7
Interpreter: PHP 7.0.8 + XDebug (or choose from [...])
Check debug config:
Preferences => Language and Frameworks => PHP => Debug => Xdebug section
All checkboxes should be checked and set Debug port to: 9001
2) run server in your app's directory:
php -S localhost:8080
3) Add localhost:8080 to PhpStorm Preferences => Language and Frameworks => PHP => Servers:
Name: Localhost:8080
Host: localhost
Port: 8080
Debugger: Xdebug
4) Update php.ini:
Php => Interpreter => […] => Configuration file - Open in Editor
Add this section: (check zend_extention path through the cli)
[Xdebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9001 (same as in Debug preferences)
5) Add Debug Configuration:
Run => Edit Configuration => add - Php Web Application
Choose Localhost:8080 server
6) Click Start Listening for Php Debug Connections
7) Set up breakpoints
7) Click on Debug (Green bug)
I'd also be interested in a better solution but I doubt there is one.
xdebug with a frontend like NetBeans, Eclipse or MacGDBp is probably where the bets go.

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.

debugging php on mac?

was wondering what was the best way to debug PHP on my local machine. I use MAMP on mac os 10.5
thanks,
Patrick
Using xdebug is a good start. Download the package and follow the instructions in the INSTALL file. It's fairly easy. Once this is done, add the following lines to your php.ini file:
;;[xdebug]
zend_extension="/Path/to/your/module/xdebug.so"
xdebug.file_link_format="txmt://open?url=file://%f&line=%1"
xdebug.var_display_max_depth = 20
Don't forget to restart Apache after this.
Most debugging can be done using a simple die(var_dump($some_variable)). It's not very sophisticated, but with xdebug installed, the output of a vardump looks pretty good in a browser. In most of the cases this is enough.
If you need more control, you can add an xdebug_break(); statement in your code and add the following lines to your php.ini:
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
Again, don't forget to restart Apache.
Now, using a tool like MacGDBp (or Eclipse+PDT if you must), you get a classic debugger. You can step though your program.
Have fun!
I've always thought the "best" way of PHP debugging on any platform is by using FirePHP, which can output debug messages straight into the Firebug window in Firefox.
I've found that running php -l myfile.php is great at catching syntax errors before I try and reload the page in my browser (and thus prevent the abominable White Screen of Death). Beyond that, I just point my browser to my local webserver and try to access the pages.
You can do some nifty things in your code itself (like using debug_backtrace()), but that (obviously) requires you to put it in the code yourself.
Personally, I use Eclipse+PDT and XDebug. To simplify things, get Eclipse for PHP Developers from the Eclipse download page rather than installing PDT as a plugin. Eclipse has a high learning curve, but it gives you all the debugger functionality you expect: instruction stepping, breakpoints, watches, even altering variables live.
If you don't like Eclipse or find it's too much for you, there are other clients compatible with XDebug.
I also use eclipse+pdt and xdebug. If you're new to trying out debuggers you can try zend studio which will setup things pretty easily.
Zend Studio is by far the best tool to use to create and debug PHP code. I run the community Edition of Zend Server on my dev Linux box and locally in a virtual machine on my MacBook Pro.
Take a look at the Zend website for details - it has cut my app development by two thirds!
Thanks to a bunch of links like this one and others, here's a compiled solutions that successfully uses OSX's native Apache2 and XDebug together with MacGDBp and a Safari extension called XDebug Helper.
You can do it even without MAMP.
There is a way how to do it using:
PhpStorm
Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Php + Xdebug
1) Install php and debug
brew install php70
brew install php70-xdebug
In PhpStorm - check Preferences => Language and Frameworks => PHP
Php language level: 7
Interpreter: PHP 7.0.8 + XDebug (or choose from [...])
Check debug config:
Preferences => Language and Frameworks => PHP => Debug => Xdebug section
All checkboxes should be checked and set Debug port to: 9001
2) run server in your app's directory:
php -S localhost:8080
3) Add localhost:8080 to PhpStorm Preferences => Language and Frameworks => PHP => Servers:
Name: Localhost:8080
Host: localhost
Port: 8080
Debugger: Xdebug
4) Update php.ini:
Php => Interpreter => […] => Configuration file - Open in Editor
Add this section: (check zend_extention path through the cli)
[Xdebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9001 (same as in Debug preferences)
5) Add Debug Configuration:
Run => Edit Configuration => add - Php Web Application
Choose Localhost:8080 server
6) Click Start Listening for Php Debug Connections
7) Set up breakpoints
7) Click on Debug (Green bug)

Categories