yaroslavche/php-project

Clean PHP8 project with installed dev-tools

0.0.6 2022-05-05 09:19 UTC

This package is auto-updated.

Last update: 2024-04-05 13:31:45 UTC


README

PHP build License Latest Stable Version PHP Version

Clean PHP 8.1 project with dev tools.

Installation

Download and install

$ composer create-project yaroslavche/php-project project-name --prefer-source

or manually

$ git clone git@github.com:yaroslavche/php-project.git project-name
$ composer install --prefer-source
Post cmd

In composer.json you can see post-install-cmd and post-create-project-cmd, which will:

  • ask needed information
  • change composer.json
  • replace all occurrences (vendor, package) in README.md
  • uncomment lines in .gitattributes
  • remove self in composer.json (if remove installer after complete)
  • remove installer (whole internal directory, by default)

Tools

PHP_CodeSniffer

squizlabs/PHP_CodeSniffer

PHP_CodeSniffer is a set of two PHP scripts; the main phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second phpcbf script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.

Check:

$ composer phpcs

Fix:

$ composer phpcbf
PHPMD - PHP Mess Detector

phpmd/phpmd

What PHPMD does is: It takes a given PHP source code base and look for several potential problems within that source. These problems can be things like: Possible bugs, Suboptimal code, Overcomplicated expressions, Unused parameters, methods, properties.

$ composer phpmd
PHPStan - PHP Static Analysis Tool

phpstan/phpstan

PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code. It moves PHP closer to compiled languages in the sense that the correctness of each line of the code can be checked before you run the actual line.

$ composer phpstan
PHPUnit

sebastianbergmann/phpunit | Writing Tests

PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.

Run tests:

$ composer phpunit

Code coverage

$ composer coverage

Will show results in console and if success, then generate build/coverage/html/ directory (see index.html in browser) and build/coverage/clover.xml (which can be useful in some cases).

Infection - Mutation Testing framework

infection/infection

Infection is a PHP mutation testing framework based on AST (Abstract Syntax Tree) mutations. It works as a CLI tool and can be executed from your project’s root.

Mutation testing is a testing methodology that involves modifying a program in small ways and analyzing reactions of the test suite on these modifications. If tests pass after the code is changed, then we have either not covered line of code or the tests are not very efficient for the mutated piece of code.

$ composer infection
Roave Security Advisories

Roave/SecurityAdvisories

Does not provide any API or usable classes: its only purpose is to prevent installation of software with known and documented security issues.