tomkyle/boilerplate-php

PHP Package boilerplate

1.1.1 2023-01-02 19:14 UTC

This package is auto-updated.

Last update: 2024-04-06 21:41:00 UTC


README

PHP Composer

A template repository for PHP package.

Start new project

$ composer create-project tomkyle/boilerplate-php new-project  
$ cd new-project
$ composer install

Requirements and suggestions

PSR standard require suggest
PSR-3 Logger implementation psr/log Monolog Logger
PSR-6 Cache Implementation psr/cache Symfony Cache component
PSR-17 HTTP factory* implementation psr/http-factory nyholm/psr7
PSR-18 HTTP client psr/http-client Guzzle 7
$ composer require monolog/monolog
$ composer require symfony/cache
$ composer require nyholm/psr7
$ composer require guzzlehttp/guzzle

Development

Run all tests

This packages has predefined test setups for code quality, code readability and unit tests. Check them out at the scripts section of composer.json.

$ composer test
# ... which includes
$ composer phpstan
$ composer phpcs
$ composer phpunit

Unit tests

Default configuration is phpunit.xml.dist. Create a custom phpunit.xml to apply your own settings. Also visit phpunit.readthedocs.io · Packagist

$ composer phpunit
# ... or
$ vendor/bin/phpunit

PhpStan

Default configuration is phpstan.neon.dist. Create a custom phpstan.neon to apply your own settings. Also visit phpstan.org · GitHub · Packagist

$ composer phpstan
# ... which includes
$ vendor/bin/phpstan analyse

PhpCS

Default configuration is .php-cs-fixer.dist.php. Create a custom .php-cs-fixer.php to apply your own settings. Also visit cs.symfony.com · GitHub · Packagist

$ composer phpcs
# ... which aliases
$ vendor/bin/php-cs-fixer fix --verbose --diff --dry-run

Apply all CS fixes:

$ composer phpcs:apply
# ... which aliases 
$ vendor/bin/php-cs-fixer fix --verbose --diff

On PHP 8.2, setting environment variable PHP_CS_FIXER_IGNORE_ENV is needed:

$ PHP_CS_FIXER_IGNORE_ENV=1 composer phpcs