During previous articles, we installed some dependencies and plugins for PhpStorm and Laravel. Now let’s dive into the configuration part.
Next, we will go over and configure anything exclusive to PhpStorm.
You can choose any language level and install the executable. PhpStorm will provide insights into your code based on the PHP version.
Good to have — format only changed lines. Keeps your PRs smaller and more focused.
When you open a new file for edit, selected items of a class are folded, so you can get a nice overview of the whole file without listing too much.
We already touched on the inspections topic in my first article in this series. Right now we are going to enable PSR-12 inspections, which are disabled by default in new installs. PHP > Code style > PSR-12
Apart from that, I recommend enabling all inspections for PHP and then disabling them 1 by 1 if something annoys you (like “Every class should have a PhpDoc”).
Just a helper template for when you need to create new files in your project. For example, I like to add “
declare(strict_types=1);” to all my PHP files.
Those templates a useful for repeatable action in your classes. Example: create a unit test stub function, inject language-specific constructions like loops, if/else, etc.
And now those helpers in action example.
Next, we will configure our composer packages integration with PhpStorm.
Why lint and analyze and code?
We installed this package and configured two commands in composer.json during the previous article so now we’ll go over how one can configure it in PhpStorm integration.
You now have an automatic php linter and fixed for your open files.
We installed this package and configured one command in composer.json during the previous article so now we’ll go over PhpStorm integration.
You now have improved static analysis for php files.
For CI/CD and local development, you can use the commands we’ve added in the previous article.
composer lint composer lint-fix composer analyze
Recommended app — Husky https://typicode.github.io/husky/#/
Follow the installation guide on the site above, then add custom commands to your commit workflow (works both in console and PhpStorm).
That’s all for this series. Hope you enjoyed and learned something new.
Over time your productivity and quality of code will skyrocket when you use the right tools for the job.
Also published here.