Code analysis toolset for Prestashop module development without configuration pain.
MIT License
This package provides tools for Prestashop module development. It's made to remove the burden of intallation and configuration of essential development tools.
Quik start :
composer require --dev sebsept/ps_dev_base
composer list psdt
For easier use, I highly suggest to use command line autocompletion for composer. There's a couple options available, this one is recommanded by composer.
fill-indexes
command, to add required index.php files. (see below for details)More tools will come ...
This package is composer plugin, it adds new commmands to composer command line tool.
These commands are under the namespace psdt
(PrestaShop Developement Tools).
The first time a command is run, a composer script is also added.
For example, the php-cs-fixer can be invoked with composer psdt:php-cs-fixer
.
You can even take an additionnal step by defining an alias.
composer psdt:php-cs-fixer [--reconfigure]
Formats php files for complying with the Prestashop standards. This allows consistent code base.
Provided by PrestaShop/php-dev-tools/. Autoinstallation provided by this package.
Allows complying with the Prestashop standards.
On the first run (or when --reconfigure
option is used):
composer php-cs-fixer
The next runs will run the fixer. All files will be formated according to the Prestashop standard.
composer psdt:phpstan [--reconfigure]
Run phpstan configured with Prestashop standards against a PrestaShop installation.
Provided by PrestaShop/php-dev-tools/. Autoinstallation provided by this package.
The first run or composer psdt:phpstan --reconfigure
do :
prestashop/prestashop-dev-tools
will be installed (if needed)phpstan
The next runs will trigger composer psdt:phpstan
composer psdt:fill-indexes [--check-only]
Add the missing index.php files on each folder. Existing index.php files are not overriden.
--check-only
option only list the missing index.php files without adding them.
This option is usefull for running in the git's pre-commit hook.
This is a security requirement of Prestashop to avoid the contents to be listed.
More information on the official documentation.
I can't include prestashop/autoindex because it targets php 5.6 and has other issues. My replacement is simpler and doesn't require additionnal dependencies.
composer psdt:pre-commit [--reconfigure]
precommit.sh
file is added.git/hooks/pre-commit
is createdpre-commit
is addedBefore a commit is performed the composer script pre-commit
will be triggered and must succeed (return 0), otherwise the commit is aborted.
The commands in composer pre-commit
script hook are provided by command implementing the PreCommitRegistrableCommand
interface.
This is currently phpstan
, php-cs-fixer
and fill-indexes
You can tweak the script by just editing the composer script.
You can run the composer psdt:pre-commit
(or composer run-script pre-commit
) to predict if commit will fail or not.
composer require --dev sebsept/ps_dev_base
php-cs-fixer and phpstan configuration and bootstraping are provided by PrestaShop/php-dev-tools/. Repository actions are made by github workflows.
See is issues in this GitHub repository.
Install the precommit hook with ln -s $(pwd)/precommit.sh .git/hooks/pre-commit
(works on linux).
Ensure to also make the file executable chmod +x precommit.sh
.