Skip to content

trayto-com/php-coding-standards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trayto.com | PHP Coding Standards

Common coding-standard utils, tools and rules used across our PHP projects in trayto.com

symplify/easy-coding-standard (ECS) is used under the hood. Follow configuration instructions there. Phar version is used so there should be no conflicts with projects dependencies.

Parallel Lint is available as well.

Further reading:

Installation instructions

composer require --dev trayto-com/php-coding-standards

Usage

You can use ECS directly in CLI but we do recommend to customise default rules:

vendor/bin/ecs check src tests --config vendor/trayto-com/php-coding-standards/definitions/ecs-default.php

Run PHP Parallel Lint:

vendor/bin/parallel-lint --exclude temp --exclude vendor .

Hint: do run linter before any other Standards check or Tests to fail fast in case of typo in your code

Customise ECS rules and custom usage

Recommended is to create your own configuration for project and define cache folder for EasyCodingStandard as well.

Create php file in your project root, for example ecs.php:

<?php declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $configurator): void {
    // make sure you import correct file
	$configurator->import(__DIR__ . '/vendor/trayto-com/php-coding-standards/definitions/ecs-default.php');

	$services = $configurator->services();
	// ... customise your services

	$parameters = $configurator->parameters();
	// .. customise your parameters

	$parameters->set(
		Option::CACHE_DIRECTORY,
		__DIR__ . '/temp/ecs'
	);
};

About

Common coding-standard utils, tools and rules used across our projects in trayto.com

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages