PHP CS Fixer configuration for Cartalyst projects

v2.0.0 2022-02-09 10:48 UTC

This package is auto-updated.

Last update: 2024-07-09 16:04:29 UTC


This repository provides a base configuration for friendsofphp/php-cs-fixer, which we use to verify and enforce a single coding standard for PHP code written on Cartalyst.


Run the following:

composer require --dev cartalyst/php-cs-fixer-config


Now that the package is installed, create a configuration file called .php_cs or .php_cs.php at the root of your project with the following contents:


// Create a new CS Fixer Finder instance
$finder = PhpCsFixer\Finder::create()->in(__DIR__);

return Cartalyst\PhpCsFixer\Config::create()

Ignoring files and/or directories

There will be certain situations where you might want to ignore certain files or directories to not be linted.

Luckily, this is quite easy to achieve and all you need to do is to perform some calls on the CS Fixer Finder instance :)

Here's a simple example where we ignore both files and directories:


// Directories to not scan
$excludeDirs = [

// Files to not scan
$excludeFiles = [

// Create a new CS Fixer Finder instance
$finder = PhpCsFixer\Finder::create()
    ->filter(function (\SplFileInfo $file) use ($excludeFiles) {
        return ! in_array($file->getRelativePathName(), $excludeFiles);

return Cartalyst\PhpCsFixer\Config::create()->setFinder($finder);

Enforce coding standards for PHPUnit tests

If you would like to also enable coding standards on your tests, you can call the withPHPUnitRules() method on the Config class, like so:


// Create a new CS Fixer Finder instance
$finder = PhpCsFixer\Finder::create()->in(__DIR__);

return Cartalyst\PHPCsFixer\Config::create()


Thank you for your interest in PHP CS Fixer Config. Here are some of the many ways to contribute.


If you discover any security related issues, please email instead of using the issue tracker.


PHP CS Fixer Config is licenced under the BSD 3-Clause. Please see the license file for more information.