PHP Quality Assurance
On this page we are going to talk about tools and techniques that we use in order to maintain the highest standard s of PHP development.
PHP QA Pipeline¶
We have created an open source BASH based PHP quality assurance pipeline that is designed to be run locally and possibly also as part of a CI pipeline
https://github.com/edmondscommerce/phpqa
The documentation for this tool is in the README file so there is not point repeating it here, however to install it in your project you simply go:
composer require edmondscomerce/phpqa --dev
Then once this is installed, simply:
bin/qa
PHPStorm¶
You should use PHPStorm to the fullest extent to ensure that you are writing code that is compliant with the QA standards.
Thankfully there are many really useful and time saving tools within PHPStorm that can make this really easy for you, from automatically fixing issues to clearly highlighting them as your write your code.
Inspections¶
- PHP Inspections (EA extended). Follow plugin link, to read through installation process and how to "Inspect code".
PHP QA Settings¶
- PHP QA also has some standard configuration to help you. To install these follow the instructions here
- Once the templates have been imported they will be used each time you create a new file / class in PHPStorm
- The Code Style may need to be manually set on a per project basis. To do this open the settings menu, and go to Editor -> Code Style -> PHP. In the Scheme dropdown make sure PHPQA is selected.
- Bring up the Reformat File Dialog, Code -> Show Reformat File Dialog or
[Ctrl] + [Alt] + [Shift] + L
and make sure the three optional tags are selected
PHP Quality Assurance Tools¶
Here are instructions on using some tools to help assist with creating high quality PHP code