codinglabsau/php-styles

Coding Labs styles for PHP-CS-Fixer

dev-main 2024-07-04 23:11 UTC

This package is auto-updated.

Last update: 2024-11-04 23:50:11 UTC


README

A PHP-CS-Fixer ruleset to share across projects, inspired by this Tim MacDonald article.

Installation

Via Composer

$ composer require codinglabsau/php-styles

Usage

Create .php-cs-fixer.dist.php in the root of the project:

<?php

$finder = PhpCsFixer\Finder::create()
    ->in([
        __DIR__.'/app',
        __DIR__.'/config',
        __DIR__.'/database',
        __DIR__.'/routes',
        __DIR__.'/tests',
    ]);

return CodingLabs\styles($finder);

Note the second argument for styles is an array of rules to override the defaults.

Do a dry run like this (handy for CI): ./vendor/bin/php-cs-fixer fix --dry-run

And do a proper fix like this: ./vendor/bin/php-cs-fixer fix

Contributing

This package is opinionated to our preferred code style at Coding Labs and subject to change, so use with caution!

Credits

License

MIT. Please see the license file for more information.

About Coding Labs

Coding Labs is a web app development agency based on the Gold Coast, Australia. See our open source projects on our website.