Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
/ps_dev_basePublic archive

Code analysis toolset for Prestashop module development without configuration pain.

License

NotificationsYou must be signed in to change notification settings

SebSept/ps_dev_base

Repository files navigation

This package providestools forPrestashop module development.
It's made toremove the burden of intallation and configuration of essential development tools.

code quality

Quik start :

composer require --dev sebsept/ps_dev_basecomposer list psdt

Requirements

  • Have composer 2 installed (not composer 1.x). If you do not have composer, it's time tostart learning it.
  • Your module must require php >= 7.2.5

For easier use, I highly suggest to use command line autocompletion for composer.
There's a couple options available,this one isrecommanded by composer.

Featured tools

  • Code formating :php-cs-fixer configured using prestashop standard, ready to use out of the box.
  • Code analysis :phpstan autodetect PrestaShop root directory or asks (nothing more to do).
  • fill-indexes command, to add required index.php files. (see below for details)
  • git pre-commit hook installer (details below)

More tools will come ...

How does it work ?

This package is composer plugin, it adds new commmands to composer command line tool.
These commands are under the namespacepsdt (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 withcomposer psdt:php-cs-fixer.
You can even take an additionnal step bydefining an alias.

Provided commands

php-cs-fixer

composer psdt:php-cs-fixer [--reconfigure]

Formats php files for complying with the Prestashop standards.This allows consistent code base.

Provided byPrestaShop/php-dev-tools/.
Autoinstallation provided by this package.

Allows complying with thePrestashop standards.

On the first run (or when--reconfigure option is used):

  • thePrestaShop/php-dev-tools package will be installed if needed.
  • .php_cs file will be (re)created with the Prestashop standard styles. (Destructive operation, get your files under version control!)
  • the composer scriptphp-cs-fixer will be added. So you can invoke this command withcomposer php-cs-fixer

The next runs will run the fixer. All files will be formated according to the Prestashop standard.

phpstan

composer psdt:phpstan [--reconfigure]

Run phpstan configured withPrestashop standards against a PrestaShop installation.

Provided byPrestaShop/php-dev-tools/.
Autoinstallation provided by this package.

The first run orcomposer psdt:phpstan --reconfigure do :

  • packageprestashop/prestashop-dev-tools will be installed (if needed)
  • creates/overrides the phpstan.neon configuration with Prestashop standards.
  • guess the _PS_ROOT_DIR_ and asks for confirmation (or you can provide another path) (this path is needed for analyse)
  • install a composer scriptphpstan

The next runs will triggercomposer psdt:phpstan

fill-indexes

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 informationon the official documentation.

I can't includeprestashop/autoindex becauseit targets php 5.6 and has other issues.
My replacement is simpler and doesn't require additionnal dependencies.

Git Pre-commit hook installer

composer psdt:pre-commit [--reconfigure]

  • precommit.sh file is added
  • symlink it to.git/hooks/pre-commit is created
  • symlink is made executable
  • composer scriptpre-commit is added

Before a commit is performed the composer scriptpre-commit will be triggered and must succeed (return 0), otherwise the commit is aborted.

The commands in composerpre-commit script hook are provided by command implementing thePreCommitRegistrableCommand interface.
This is currentlyphpstan,php-cs-fixer andfill-indexes

You can tweak the script by just editing the composer script.
You can run thecomposer psdt:pre-commit (orcomposer run-script pre-commit) to predict if commit will fail or not.

Installation

composer require --dev sebsept/ps_dev_base

Under the hood / Credits

php-cs-fixer andphpstan configuration and bootstraping are provided byPrestaShop/php-dev-tools/.
Repository actions are made bygithub workflows.

What's next ?

See is issues in this GitHub repository.

Development notes (for this package)

Install the precommit hook withln -s $(pwd)/precommit.sh .git/hooks/pre-commit (works on linux).Ensure to also make the file executablechmod +x precommit.sh.


[8]ページ先頭

©2009-2025 Movatter.jp