10/1/16
https://flickr.com/photos/25348945@N06/3994456259/
Baby Steps -> Giant Leaps
(aka Xdebug for Beginners)
By Sean Prunka
Presented at MadisonPHP 2016-10-01
Baby Steps?Giant Leaps?What is this, the Lunar Lander? Parcour?
Nope... No rocket science here. No death defying high rise obstacle courses either.
WHOAMI?
Daddy
PHP Dev
Actor
LGBTQIA+
6 kids. From 17 down to 4.
I played with PHP first in 1998-99. kept playing with it for 12 yrs. Then ZendCon. In all, that's more than 15 yrs of PHP experience. ZCE PHP 5.3 Senior Developer @ PO2Go
Over 35 yrs of acting experience, including school and community. Active with several local community theatres currently, including being a founding member on the board of a new one.
Pansexual, Genderfluid/GenderQueer. Cville Pride, Shenandoah Valley Pride.
What I hope to impart:
What Xdebug is.
How to install Xdebug.
How to set up your IDE to use Xdebug.
How to set break points.
How to step through your code and see what's going on.
How to skip over the boring parts.
https://flickr.com/photos/10786001@N05/3905561114/
What is Xdebug?Sooooo.... What is Xdebug?
What is Xdebug?
Xdebug is a tool to make your developing life easier.It is a PHP extension that you can just pop into place and start using.
Xdebug - Debugger and Profiler Tool for PHP (Xdebug.org, site title)
Xdebug: A powerful debugger for PHP. (Xdebug.org, site decription)
Xdebug is a PHP extension which provides debugging and profiling capabilities. (Wikipedia, with its own source.)
Open Source. Made with dedication by Derick Rethans (and some helpers)
Available on GitHub
Xdebug is a Step debugger.The how of it all is magic to me. Your
IDE listens for a cookie and your browser sends a cookie and
magically you are stepping through your *local* code that is the
same as the code existing in your VM, or on your server.
Development, Staging, or Production. You can run with Xdebug anywhere.
I'm sure there are plenty of caveats to that, but it pretty much just works
https://flickr.com/photos/10786001@N05/3905561114/
How Do I Install It?The hard way: build from scratch.
The easier ways:PECL/PEAR
Mac Homebrew
The easiest:
It's already installed/baked into your PHP installation.
PECL:# pecl install xdebug
Homebrew (on a Mac)
# brew install -xdebug
Apt/Yum/etcThese methods will vary from distro to distro and repo to repo.
Build from source.This is beyond the scope of this talk, check Xdebug.org for details.
Maybe it's already installed!Fire up a phpinfo() to check.
(don't forget to change the path and filename to the correct one but make sure you use the full path)
Configure PHP to Use Xdebug
add the following line to php.ini (or in a separate file, if you have your INI set to read a a sub-directory or such.)
[xdebug]zend_extension="/usr/lib64/php/modules/xdebug.so"xdebug.remote_enable = 1
Restart your webserver.
Load up a 'phpinfo()' page. You should see the fact it is loaded and some details.
Taken From: http://wiki.netbeans.org/HowToConfigureXDebug
Xdebug is incompatiblewith theZend Optimizer and Zend Studio Debugger extensions. These extensions should be commented out.
From PHP 5.3 onwards, you need to use zend_extension and not zend_extension_ts.
Get xdebug's debugclient working on localhost first, then add Netbeans. Use the bundled command line client "debugclient" on localhost, debugging simple php code (e.g. a phpinfo file), with any firewalls and other competing factors or config disabled or removed. When you've got this running, then your fight with Netbeans will be on solid ground, and will probably be surprisingly easy.
Instructions on installing Debugclient are cunningly hidden right at the bottom of http://www.xdebug.org/docs/install
If you are mapping server paths to project paths, you must map the full project folders to each other, not the parent folders.
More Info on Debugging in Netbeans here: https://netbeans.org/kb/docs/php/debugging.html
https://flickr.com/photos/9328058@N08/4503893385/
Configuration (Netbeans)I don't use Netbeans anymore, and all the configuration related to Xdebug that I could find deal more with the configuration of Xdebug itself, not necessarily in conjunction with Netbeans.
So, I just ended up grabbing a screenshot from the web.
https://flickr.com/photos/127470644@N06/15031496788/
Configuration (Zend Studio)It's been even longer since I used Zend Studio, and they tend to prefer you using Zend Debugger, so I just grabbed another screen shot from the web.
https://flickr.com/photos/66854529@N00/314448550/
Configuration (PhpStorm)PhpStorm is my current go-to IDE
No screenshot:
Drop to Local PhpStorm installation.
https://flickr.com/photos/9791645@N07/16892552068/
Lights, Camera, Action!
Getting Xdebug to react!
Using a Browser Extension(Ideas from JetBrains wiki. More there.) Chrome: Xdebug helper
Firefox: easy Xdebug
Using Bookmarklets https://www.jetbrains.com/phpstorm/marklets/
http://tool.ihacklog.com/xdebug-bookmarklet/
Using a cookie (This is basically all both of the above utilities are doing.)
Name: XDEBUG_SESSION
Value: (varies by IDE)
Triggering Xdebug requires a cookie. That's it.I use a handy Extension in Chrome called Xdebug helper.There are also handy extensions for Firefox, Safari, and Opera. Not sure about IE.who uses IE for dev anyway???
If you either don't want to or are unable to install an extension, that's fine, you can add a bookmarklet, or just add a cookie and add XDEBUG_SESSION_START to the path.
https://flickr.com/photos/36515592@N00/12115474835/
SteppingSince Xdebug is a STEP debugger, let's get stepping, shall we??
https://flickr.com/photos/62445783@N04/14316417902/
Step In
https://flickr.com/photos/62445783@N04/14316417902/
Step Out
https://flickr.com/photos/19059244@N00/5086817836/
Hokey Pokey?
Nothing to see in the slides.
Drop to PhpStorm and demo!
https://flickr.com/photos/19575742@N04/2214287842/
Skipping
Nothing to see in the slides.
Drop to PhpStorm and demo!
https://flickr.com/photos/38229258@N03/4665070783/
Ready to take that Giant Leap?
https://flickr.com/photos/23679420@N00/545653437/
So Long and Thanks for all the Fish!
Many thanks to MadisonPHP for hosting this amazing conference and bringing me here to speak. Thanks also to the wonderful sponsors.And a HUGE thank you to you for putting up with my rambling and raving.
Twitter: @sprunkaEmail: [email protected]: https://joind.in/talk/177b7
Useful Links!
Xdebug: http://xdebug.org/
PhpStorm setup: https://goo.gl/Ihn7Eb
PhpStorm page about browser extensions: https://goo.gl/eiztW2
Netbeans page about setting up Xdebug: https://goo.gl/aNv2Dz
Netbeans specific help: https://goo.gl/Bawypj
Juan Treminio (the Puphpet.com guy) blog post: https://goo.gl/SZWvXF
Top Related