This is a subject that seems to come up again and again. I figured this out once before, but back then I was using Eclipse, while I am now a PhpStorm devotee. Also, I've long since started using Vagrant, which means that every debugging scenario is now "remote". Usually, this is not a huge issue, but with command line debugging, this presents a bit of a challenge.
Randy Fay has done a nice write-up back in 2013, which covers most of the bases. It does leave one missing link, which seems to have come up only recently; a recent change in drush has broken debugging through xdebug, because it is now using pcntl_exec() to execute the actual script (don't ask me for the technical details, I haven't delved into that too much). As is so often the case, Stack Exchange provided the missing piece of the puzzle; it's possible to circumvent the "decoupling", that seems to occur due to the pcntl_exec(), by using drush.launcher as the entry point.
As much for my own reference as anyone else's, these are the key points from both Randy's post and the SE topic:
- Set up a "PHP Web Application" for debugging the command line. The sole purpose of this is to be able to provide a path mapping when running the command in Vagrant.
- Enable xdebug debugging for the command line in your Vagrant box. In my case, this simply meant symlinking the same xdebug.ini from my /etc/php5/cli/conf.d directory as I was using in the /etc/php5/apache/conf.d for web debugging.
- All executed code needs to be available in the project, including drush. You can accomplish this by e.g. installing drush as a composer dependency (also, remember to execute drush from your project).
The following you will need to do every debugging session:
- Use PhpStorm's "Listen for PHP Debug connections" button
- Set the remote debug client on the command line using (or whatever is the IP-address for your host machine when coming from the Vagrant box; the xdebug.remote_connect_back that is likely in your config will not work for the command line):
export XDEBUG_CONFIG="idekey=phpstorm remote_host=192.168.33.1"
- Set the server configuration. Make sure the name you use matches the server name you configured in PhpStorm:
export PHP_IDE_CONFIG="serverName=cli"
- Execute drush by substituting "drush.launcher" for the regular drush command. Make sure you use the drush copy from your project. For example:
../vendor/drush/drush/drush.launcher migrate-reset-status posts
Comments
Add new comment | Blokspeed.net
Add new comment | Blokspeed.net
Egzamin Na Prawo Jazdy Online: Nowa Era Egzaminowania Kierowców egzamin na Prawo jazdy online
Add new comment | Blokspeed.net
The Evolution And Importance Of Push Chairs And Prams In Modern Parenting push chairs And prams
Add new comment | Blokspeed.net
All You Need To Know About Dolce Gusto Coffee Makers Gusto Coffee Maker
Add new comment | Blokspeed.net
Searching For Inspiration? Try Looking Up Integrated Electric Oven Integrated Electric Oven And Hob
Add new comment | Blokspeed.net
10 Things That Your Family Teach You About Leather Sofa
Clearance Leather Sofa Clearance
Add new comment | Blokspeed.net
The Reasons To Focus On Improving Auto Locksmiths Luton auto locksmith in luton
Add new comment | Blokspeed.net
Guide To Keyless Push Button Start Repair: The Intermediate Guide To Keyless Push Button Start Repair
keyless push button start repair
Add new comment | Blokspeed.net
Locksmith Car Near Me: A Comprehensive Guide To Auto Locksmith Services Locksmith Car Near Me
Add new comment | Blokspeed.net
Proximity Key Repair Tips To Relax Your Everyday Lifethe Only Proximity
Key Repair Trick Every Individual Should Know Proximity Key Repair (Brewwiki.Win)
Add new comment | Blokspeed.net
Add new comment | Blokspeed.net
The World Of Couches: Exploring Prices And Options chic Sofas
Add new comment | Blokspeed.net
Saving Space And Money: Why Cheap Bunk Beds Are A Smart Investment cheap bunk Beds
Add new comment | Blokspeed.net
Add new comment | Blokspeed.net
The 10 Scariest Things About How To Get Replacement Car
Keys how to get replacement car keys
Add new comment | Blokspeed.net
Bunk Beds Cheap Techniques To Simplify Your Daily Life Bunk Beds Cheap Trick That
Every Person Should Know Bunk beds cheap
Add new comment | Blokspeed.net
Add new comment | Blokspeed.net
A Complete Guide To African Grey Parrot Diet Plans african grey Parrot diet plan
Add new comment | Blokspeed.net
The Importance Of International English Language Testing System (IELTS) Certificate free online ielts
Course with certificate [154.8.193.216]
Add new comment | Blokspeed.net
The Comprehensive Guide To Automobile Key Repair: Understanding
Methods, Costs, And FAQs automobile Key repair (201.17.3.96)
Add new comment | Blokspeed.net
Word Rewriter Ai Tools To Improve Your Daily Lifethe One Word Rewriter Ai Trick That Every Person Should Learn Word Rewriter (163.228.224.105)
Add new comment | Blokspeed.net
9 . What Your Parents Teach You About Car Flip Key Repair Car Flip Key Repair
Add new comment | Blokspeed.net
Shop Online For Motorized Mobility Scooters: A Comprehensive Guide Shop
Online For Motorized Mobility Scooters; Http://Www.Genebiotech.Co.Kr,
Add new comment | Blokspeed.net
See What Ignition Key Repair Tricks The Celebs Are Making Use Of Ignition Key Repair (junker-Worm-2.thoughtlanes.net)
Add new comment | Blokspeed.net
Check Out: How Folding Mobility Scooter UK Is Taking Over And What Can We
Do About It Folding Motorized Scooter
Add new comment | Blokspeed.net
9 Things Your Parents Taught You About Coffee Maker Tassimo coffee maker Tassimo
Add new comment | Blokspeed.net
Car Remote Key Repair Techniques To Simplify Your Daily Lifethe One Car
Remote Key Repair Trick That Every Person Must Know
Car Remote Key Repair
Saved me. DIdn't see
export PHP_IDE_CONFIG="serverName=cli"
In other pages and I spent a couple hours trying to figure it out.