This repository includes tools to check that repositories are following the standards defined by the PrestaShop community and provides configuration files for some of them.
Related packages:
composer require --dev prestashop/php-dev-tools
## Development dependencies runtimes
composer require --dev friendsofphp/php-cs-fixer
composer require --dev phpstan/phpstan
composer require --dev prestashop/header-stamp
composer require --dev prestashop/autoindex
composer require --dev squizlabs/php_codesniffer
When this project is successfully added to your dependencies, you can enable each review tool on your projet.
Version | Status | Packagist - | Namespace | Repo | Docs | PHP Version |
---|---|---|---|---|---|---|
1.x | EOL | prestashop/php-dev-tools |
N/A | v1.x | N/A | >=5.6,<7.2 |
2.x | EOL | prestashop/php-dev-tools |
N/A | v2.x | N/A | >=5.6,<7.2 |
3.x | Security fixes | prestashop/php-dev-tools |
N/A | v3.x | N/A | >=5.6,>=7.2.5 |
4.x | EOL | prestashop/php-dev-tools |
N/A | v4.x | N/A | >=7.2.5 |
5.x | Latest | prestashop/php-dev-tools |
N/A | master | N/A | >=7.2.5 |
The configuration files added in your project can be freely modified in order to match your needs.
Running the tools can be done by calling their respective binary:
Initialize the configuration with:
$ php vendor/bin/prestashop-coding-standards cs-fixer:init [--dest /path/to/my/project]
It'll create a configuration file .php-cs-fixer.dist.php
in the root of your project.
Upgrade note : When upgrading from 4.1.0 to newer version, you should re-run the init script or rename your .php_cs.dist
file to .php-cs-fixer.dist.php
in order to match the new requirements of cs-fixer.
$ vendor/bin/php-cs-fixer fix
$ php vendor/bin/prestashop-coding-standards phpstan:init [--dest /path/to/my/project]
It'll create a default file phpstan.neon
in tests/phpstan
, that are required to run phpstan.
The default phpstan level is the lowest available, but we recommend you to update this value to get more recommandations.
$ _PS_ROOT_DIR_=<Path_to_PrestaShop> php vendor/bin/phpstan --configuration=tests/phpstan/phpstan.neon analyse <path1 [path2 [...]]>
Applying an index.php file to all your project subfolders will be useful to avoid directories to be listed by the webserver.
$ vendor/bin/autoindex prestashop:add:index <path>
Your license headers can be updated by applying the header stamp.
Here is an example of call, applying the default license on a PrestaShop module:
$ vendor/bin/header-stamp --license=assets/afl.txt --exclude=vendor,node_modules
Available options are provided with --help
.