AFUP conference feedbacks
Introduction
In order to promote knowledge sharing within PHP community, AFUP organise every year a PHP forum. This year, I was able to attend Paris's PHP Forum that took place between 24th and 25th of october. I'd like to share in this article the main topics of the last day of this forum.
Aggressive PHP Quality Insurance in 2019
During his presentation, Ocramus share with us some very useful tools to ensure code quality in production
There are several tools to ensure code quality such as:
- Psalm
Psalm is a static analysis tool for finding errors in PHP programs. You can install it with composer
composer require --dev vimeo/psalm:^3
See full documentation on Github
- Phpunit (make program robust by unit testing)
The faster way to install phpunit is by downloading PHP Archive (Phar)
$ wget https://phar.phpunit.de/phpunit-8.4.phar
$ chmod +x phpunit-8.4.phar
see full documentation here
- Behat (To add functional testings)
Behat is a framework that allow coding functional tests.Easy to install and execute.
Installation
php composer.phar require --dev behat/behat
vendor/bin/behat -V
Full documentation on behat official website here
- Phpspec
A php toolset to drive emergent design by specification. Phpspec can be added in the composer file like this:
{
"require-dev": {
"phpspec/phpspec": "^4.0"
},
"config": {
"bin-dir": "bin"
},
"autoload": {"psr-0": {"": "src"}}
}
The full Phpspec documentation can be found here
- Doctrine coding Standard
The doctrine coding standard is a PHP_CodeSniffer used on Doctrine projects. The doctrine coding standard can be use to validate a set of rules specified to validate Php code.
Basic usage
composer global require doctrine/coding-standard
phpcs --standard=Doctrine /path/to/some/file/to/sniff.php
phpcbf --standard=Doctrine /path/to/some/file/to/sniff.php
Full doctrine standard documentation here
- Phpbench
A PHP benchmark framework.
Installation
Download the phar and public key with curl as follow.
$ curl -o phpbench.phar https://phpbench.github.io/phpbench/phpbench.phar
$ curl -o phpbench.phar.pubkey https://phpbench.github.io/phpbench/phpbench.phar.pubkey
Make the phar executable and add it to the global path as below
$ chmod 0755 phpbench.phar
$ sudo mv phpbench.phar /usr/local/bin/phpbench
$ sudo mv phpbench.phar.pubkey /usr/local/bin/phpbench.pubkey
The full Phpbench documentation can be found here
Analysis and logging tools
- Tideways
- Sentry
- Instana
- Datadog
API Validator tools original website
composer require lezhnev74/openapi-psr7-validator
- Backward compatiblity checker tool full documentation
A tool that can be used to check BC (Backward Compatibility) between to PHP versions
Installation
composer require --dev roave/backward-compatibility-check
Install with docker
docker run --rm -v `pwd`:/app nyholm/roave-bc-check
Security checker tool
- Security advisories (Fulle documentation can be found here)
Ensure that your application doesn't install dependencies with know vulnerabilities. Installation:
composer require --dev roave/security-advisories:dev-master
- Composer checker & composer unused checker
composer require maglnet/composer-require-checker
composer require icanhazstring/composer-unused
Final words:
A good program is a program that: 1. Keep everything up to date 2. is stable 3. is Fast 4. is nice 5. is working