An alias to easily debug PHP scripts
As I said before, I’m trying to save some time when using the CLI, and I rely more and more on aliases.
Aliases are fantastic to save some keystrokes, and they also significantly help with something else: freeing mental space.
Some commands take a lot of arguments and options, and it’s not always simple to remember all of them. I’ve decided to stop remembering everything and created an abstraction on top of the one I often use, hiding the long list of arguments under an alias or a command. If I still have trouble remembering the alias, I can still rely on my alias to find aliases.
One of the examples of such a command with a long list of arguments is the PHP command when it comes to debugging a PHP script.
On my machine, with PhpStorm, it goes like php -dxdebug.mode=debug -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9000 -dxdebug.start_with_request=yes script.php
.
You probably could have different options on your machine.
I’ve introduced a simple alias, xdebug
, to avoid thinking about specifing mode, port and client:
alias xdebug='php -dxdebug.mode=debug \
-dxdebug.client_host=127.0.0.1
\ -dxdebug.client_port=9000
\ -dxdebug.start_with_request=yes'
Now, debugging a script is as easy as xdebug script.php
and I don’t have to look for the documentation, or look through my zsh history, to see how I need to construct my command.
Keystrokes and time saved, memory freed!
- Improve your automated testing : You will learn how to fix your tests and make them pass from things that slow you down to things that save you time. This is a self-paced video course in French.
- Helping your teams: I help software teams deliver better software sooner. We'll work on technical issues with code, test or architecture, or the process and organization depending on your needs. Book a free call where we'll discuss how things are going on your side and how I can help you.
- Deliver a talk in your organization: I have a few talks that I enjoy presenting, and I can share with your organization(meetup, conference, company, BBL). If you feel that we could work on a new topic together, let's discuss that.