Share your PHP best practices with your team in PHPStorm
Tags: programming, php, productivity, codequality
Published: 2022-03-11 17:01:15

According to [The State of Developer Ecosystem 2021](https://www.jetbrains.com/lp/devecosystem-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](https://plugins.jetbrains.com/plugin/15503-promyze) plugin and create an account on [Packmind](https://subscribe.promyze.app) 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](https://github.com/alexeymezenin/laravel-best-practices), 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mq1qx3uavxp9s46oh7in.gif)

## #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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/09i2ek6jfpxa1me03t3i.gif)

## #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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d4xpepxoyd8ua5bq2zcw.png)

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

![Best practice correction](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qg4suq09ch2iy6e3kzy9.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/alizlw6v9my8lj9k1szj.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2wsyywustl8y3xgavz8k.gif)

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](https://packmind.com).