DEV Community

Cédric Teyton for Packmind

Posted on • Updated on • Originally published at packmind.com

Share your PHP best practices with your team in PHPStorm

According to The State of Developer Ecosystem 2021 released by JetBrains, PhpStorm is the most popular IDE used by PHP developers, while VS Code stands second.

If you rework code, share your contributions with your team

If you’re a PHP developer and work as a team, you may already have met source code in your project that you must rework to make it more understandable. You did so because you were convinced some best practices were not applied. The author of the source code probably did not know them or did not realize a bad practice was introduced. These practices can be related to PHP itself, Lavarel/Symfony usage, Performance, Security, or any topic of interest.

In any case, that was an excellent opportunity for you to make the code cleaner. However, it would be even more efficient if the author took knowledge of your action. Let’s go further: what if your whole team could benefit from your changes? And even other teams in your organization?

Let’s see how to achieve that.

#1 Catch an example of best practice in PhpStorm

First, you’ll have to install the Packmind plugin and create an account on Packmind to get your API key.

Once everything is ready, just keep on coding until you realize a specific code snippet does not follow a best practice. Let’s take a simple example with this Laravel best practice, but assume you’ll define a practice specific to your context.

It’ll take you no more than 30 seconds to catch this snippet of code and send it to Packmind.

Best practice suggestion

#2 Optional: Share the correction

If you’re going to edit the code to ensure the best practice is applied, you can also do it with the plugin Packmind. Here is an example of correction:

Best practice correction

#3 Discuss best practices with your team

Thanks to Packmind, anyone in your team can perform the same operations as you did. All these contributions are sent to Packmind, a Web application that records all your best practices. But this is also a place where you can run team meetings, called Craft Workshops, that are dedicated to reviewing each developers’ contributions and validating them or not.

For instance, I (Bob) will explain to my team why I think this is a bad practice:

Best practice introduction

I can show the code in detail to see before/after my correction:

Best practice correction

Then we’ll decide together if we agree or not to keep this practice.

#4 Tune Packmind’s automatic algorithm

Once you’ve validated your best practice with your team, you can use regular expressions or tokens to help Packmind to provide you with relevant suggestions in PhpStorm.

Regular expressions configuration

Now, every time your or your teammates will use magic strings instead of translations systems, they’ll receive a notification telling us their code is not following a best practice:

Best practice suggestion

Packmind has plugins for all the JetBrains suite, VS Code, Visual Studio and Eclipse, as well as for web browsers.

🚀 Want to give it a try? Start your 30-days trial on packmind.com.

Top comments (0)