As software engineers, our job is mainly to think a lot and write code (as little as possible). Writing code can be tedious, especially with Laravel where in many places it relies on pure “magic”, for example, model magic properties and methods, DB builder’s fluent API, and DI for interfaces.
You can’t always rely on your memory of what fields or relations each model at your project has, say 6 months after you finished initial development. Without good insight from your IDE, you’d feel lost in your older classes. So in this article, I want to share how I set up my Laravel projects within the PhpStorm IDE that boost my productivity levels by a lot.
Not only that — having IDE find possible bugs for you way before they even hit a Pull Request is priceless. Having an IDE hint to you where your code can be simplified and/or refactored — is priceless.
By just having the right IDE setup — you can learn and grow, meanwhile producing quality code and software.
It provides a list of inspections that will validate your code on the fly. This is the list of mistakes you are not going to make thanks to a great IDE. Extensible with plugins.
This is a really powerful tool, it will use a combination of your preferences + PHP Code Sniffer linter, a config that you can share with the team.
Node.js development is also not a problem. PhpStorm under the hood is WebStorm + PHP so it provides the same utility as WebStorm for JavaScript development. Prettier or ESLint config is not a problem.
Double Shift (Shift + Shift) — opens the “Search Everywhere” dialog, and type in the class or file name. Use Alt + Left/Right arrows to switch tabs to “Classes/Files/Symbols’’ to narrow the search. This is one of the best tools to navigate your codebase when you do not recall exactly what the class name is (or when you know exactly and go straight to the expected file).
Very nice thing to have for bigger projects. Automatic model properties discovery and hints while typing them in various array input/output situations.
Git blame, visual interface for — commit and push, switching branches, merge conflict resolving, etc.
This concludes the first part of my series for Laravel productivity with PhpStorm. In my next article, I will share the minimum viable local environment setup for Laravel development with PHP, Node.js, MySQL, and Redis.
Also published here.