PhpStorm is my code editor of choice and it’s robust. Almost to powerful because it has an immense set of features and settings. I wanted to show you some of the tips and tricks I have learned over the past few months and my workflow.
PhpStorm allows you to rebind every keybinding and even add bindings to features that are not mapped. This means you can set it up to perfectly match your existing workflow, and if moving from another editor you will feel right at home with just a few minutes of setup time.
Way back in 2001 is when I first started down the rabbit hole of web development. Since that time I’ve used a handful of primary editors with Sublime being the latest. I am so accustomed to it that I duplicated Sublimes keybindings to PhpStorm. Here is a full list of all my customized keys:
- Command-p – Search Everywhere
- Command-r – Methods in file
- Alt-Command-p – Switch Projects
- Command-3 – Open the integrated terminal
As you can see I didn’t customize a lot, just made it more comfortable.
The preferences are vast, you can customize so much that it’s impossible to cover everything. Here are the custom changes I settled on:
- Coming from Sublime Text a major feature I used was selecting a word and hitting a single quote or double quote to surround the selected text. PhpStorm enables this from the Preferences -> IDE -> Editor -> Smart Keys -> Surround Selection on typing quote or brace.
- Preferences -> IDE -> Editor -> Appearance -> Show method separators. This puts a line between methods to give them a more blocky feel. Reminds me of my old CodeIgniter days and its docblocks.
- Preferences -> IDE -> Editor -> Auto Import. I checked all these which will convert a full namespaces into use statements. For example typing:
ShoppingPaymentGatewaymoves this into a
use ShoppingPaymentGatewaystatement and leaves
Gatewayat the caret position. This makes the code feel cleaner to me.
- Setup Laravel live templates. Koomai keeps adding useful templates and pressing CMD+J will show the popup that you can easily search for what you are looking for.
Improving the workflow
My current workflow is I open my project, launch the integrated terminal and run
grunt watch. Next hide the terminal and start my day coding. I use the built-in VCS operations and I have tasks setup to pull issues from GitHub and Trello cards. From here it’s just basic operations. Open files, search, find usages, and go to declaration. Here is the list of features I use the most (Help -> Productivity Guide):
Now that I have a few months of using it under my belt I’m ready to go to the next level. But the question I always have is what do I want? What would improve my personal workflow? What is the name of the option I’m looking for? Nine times out of ten PhpStorm has it, but I struggle articulating what I’m looking for to find it in the docs.
To help me improve and find some power features I decided to ask on Twitter and had some great responses that I’m going to share here:
Command/Control+Shift+Backspace. This will take you to your last edit point.
Double press “Shift” brings up a global search. Very useful.
There are a few that I have found super useful so far.
- CMD+SHIFT+A – Find Action… It’s similar to CMD+SHIFT+P in Sublime. Allows you to search for functionality in the editor.
- SHIFT+SHIFT – Search Everywhere – A beefier version of Sublime’s CMD+P
- Setup your coding standards in Preferences > Code Style. Then when in a file, hit CMD+OPT+L to format the whole file, or selected code, to those standards. I still miss Sublime’s Abacus plugin, since PhpStorm isn’t as good as aligning variable signs, but it works well enough.
- CTRL+OPT+I – Auto-indent Lines. – Doesn’t tweak your coding style, just properly indents the code you have typed.
The remote bash commands are really useful. I have one set up with a key command that will start behat tests on a VM or remote machine of the feature file that’s currently in focus prompting you for additional params!
If your cursor is on a function or class name, hit command+B to jump to its declaration.
It isn’t all cakes and pies, I do have some minor annoyances that I haven’t been able to adjust in the settings. The biggest is going to the top or bottom of a file. In most apps Command-Up or Command-Down takes you to the top or bottom. This is not the case for PhpStorm and I have no idea how to change it.
Of course, a big complaint I keep hearing is that PhpStorm is slow. At first, I noticed those extra milliseconds but it more than makes up for this in all it’s other features. Now I am so accustomed that I rarely even notice.
As you can see I’m fond of PhpStorm and the future looks bright. JetBrains are receptive to feedback and are always improving. This gives me reassurance that it isn’t going to be abandoned like some other editors. CoughFiled in: Development Tools / PhpStorm
- Senior Full-Stack Developer
Atlanta, GA - (remote) USA ONLY
- PHP Laravel Developer
ApproveMe // Document Signing
- Wordpress and/or Laravel Developer
Remote (Lexington, KY)
- Software Developer
Join 31,000+ others and never miss out on new tips, tutorials, and more.
Use statements in code design
Rob Allen writing about use statements in code design. I came to the same conclusion as Rob and much prefer importing…
Extending The Connection Class In Laravel
Sometimes you may wish to extend the database Connection class in Laravel. Maybe you want to customize the internal w…