All Projects â†’ ergebnis â†’ php-cs-fixer-config

ergebnis / php-cs-fixer-config

Licence: MIT License
📓 Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

Programming Languages

PHP
23972 projects - #3 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to php-cs-fixer-config

ienv
Improved shell environment: sane dotfiles backed by my daily work optimized for solarized theme
Stars: ✭ 25 (-13.79%)
Mutual labels:  configuration
config-parser
A slim, fully managed C# library for reading/writing .ini, .conf, .cfg etc configuration files.
Stars: ✭ 67 (+131.03%)
Mutual labels:  configuration
easy-props
The simple, stupid properties library for Java
Stars: ✭ 76 (+162.07%)
Mutual labels:  configuration
giulius
Tools for loading file-based configuration files and mapping them with Guice's ``@Named`` and more
Stars: ✭ 18 (-37.93%)
Mutual labels:  configuration
MEMCM-OSD-Scripts
OSD Scripts
Stars: ✭ 34 (+17.24%)
Mutual labels:  configuration
sccm
Microsoft System Center Configuration Manager
Stars: ✭ 21 (-27.59%)
Mutual labels:  configuration
harg
Haskell program configuration using higher kinded data
Stars: ✭ 23 (-20.69%)
Mutual labels:  configuration
org-starter
Configure files and directories in Org mode more easily
Stars: ✭ 73 (+151.72%)
Mutual labels:  configuration
puppet-augeasproviders
Alternative Augeas-based providers for Puppet
Stars: ✭ 64 (+120.69%)
Mutual labels:  configuration
env
A lightweight package for loading OS environment variables into structs for Go projects
Stars: ✭ 24 (-17.24%)
Mutual labels:  configuration
php-cs-fixer-config
📓 Provides a configuration for friendsofphp/php-cs-fixer, used within Refinery29.
Stars: ✭ 43 (+48.28%)
Mutual labels:  php-cs-fixer
config
Configure your application in PHP, with PSR-11 implementation
Stars: ✭ 19 (-34.48%)
Mutual labels:  configuration
gconfigs
gConfigs - Config and Secret parser
Stars: ✭ 42 (+44.83%)
Mutual labels:  configuration
Flutter-Global-Config
A flutter package for managing different configurations and making them available everythere inside the app.
Stars: ✭ 88 (+203.45%)
Mutual labels:  configuration
road-to-orleans
This repository illustrates the road to orleans with practical, real-life examples. From most basic, to more advanced techniques.
Stars: ✭ 55 (+89.66%)
Mutual labels:  configuration
dhall-scala
dhall-scala is a Scala library for consuming dhall configuration files from Scala programming language.
Stars: ✭ 39 (+34.48%)
Mutual labels:  configuration
flagga
An extensible Go library for handling program configuration using flags.
Stars: ✭ 28 (-3.45%)
Mutual labels:  configuration
colt
A configuration utility for Python objects inspired by AllenNLP.
Stars: ✭ 17 (-41.38%)
Mutual labels:  configuration
ZConfer
The ultimate ZSH configuration utility.
Stars: ✭ 26 (-10.34%)
Mutual labels:  configuration
killer-storybook-config
A killer Storybook Webpack config to help you bootstrap a great storybook config ASAP. It includes a React Frontend, GraphQL compatibility for Storybook, TypeScript, Babel, and ESlint.
Stars: ✭ 32 (+10.34%)
Mutual labels:  configuration

php-cs-fixer-config

Integrate Prune Release Renew

Code Coverage Type Coverage

Latest Stable Version Total Downloads

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

Installation

Run

$ composer require --dev ergebnis/php-cs-fixer-config

Usage

Configuration

Pick one of the rule sets:

Create a configuration file .php-cs-fixer.php in the root of your project:

<?php

use Ergebnis\PhpCsFixer\Config;

$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php74());

$config->getFinder()->in(__DIR__);
$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');

return $config;

Git

All configuration examples use the caching feature, and if you want to use it as well, you should add the cache directory to .gitignore:

+ /.build/
 /vendor/

💡 Personally, I prefer to use a .build directory for storing build artifacts.

Configuration with header

💡 Optionally specify a header:

 <?php

 use Ergebnis\PhpCsFixer\Config;

+$header = <<<EOF
+Copyright (c) 2020 Andreas Möller
+
+For the full copyright and license information, please view
+the LICENSE file that was distributed with this source code.
+
+@see https://github.com/ergebnis/php-cs-fixer-config
+EOF;

-$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php74());
+$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php74($header));

 $config->getFinder()->in(__DIR__);
 $config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');

 return $config;

This will enable and configure the HeaderCommentFixer, so that file headers will be added to PHP files, for example:

<?php

/**
 * Copyright (c) 2020 Andreas Möller
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 *
 * @see https://github.com/ergebnis/php-cs-fixer-config
 */

Configuration with override rules

💡 Optionally override rules from a rule set by passing in an array of rules to be merged in:

 <?php

 use Ergebnis\PhpCsFixer\Config;

-$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php74());
+$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php74(), [
+    'mb_str_functions' => false,
+    'strict_comparison' => false,
+]);

 $config->getFinder()->in(__DIR__);
 $config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');

 return $config;

Makefile

If you like Makefiles, create a Makefile with a coding-standards target:

+.PHONY: coding-standards
+coding-standards: vendor
+	 mkdir -p .build/php-cs-fixer
+    vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose

 vendor: composer.json composer.lock
     composer validate
     composer install

Run

$ make coding-standards

to automatically fix coding standard violations.

Composer script

If you like composer scripts, add a coding-standards script to composer.json:

 {
   "name": "foo/bar",
   "require": {
     "php": "^7.3",
   },
   "require-dev": {
     "ergebnis/php-cs-fixer-config": "~1.0.0"
+  },
+  "scripts": {
+    "coding-standards": [
+      "mkdir -p .build/php-cs-fixer",
+      "php-cs-fixer fix --diff --verbose"
+    ]
   }
 }

Run

$ composer coding-standards

to automatically fix coding standard violations.

GitHub Actions

If you like GitHub Actions, add a coding-standards job to your workflow:

 on:
   pull_request: null
   push:
     branches:
       - main

 name: "Integrate"

 jobs:
+  coding-standards:
+    name: "Coding Standards"
+
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        php-version:
+          - "7.3"
+
+    steps:
+      - name: "Checkout"
+        uses: "actions/checkout@v2"
+
+      - name: "Install PHP with extensions"
+        uses: "shivammathur/setup-php@v2"
+        with:
+          coverage: "none"
+          php-version: "${{ matrix.php-version }}"
+
+      - name: "Cache dependencies installed with composer"
+        uses: "actions/cache@v2"
+        with:
+          path: "~/.composer/cache"
+          key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}"
+          restore-keys: "php-${{ matrix.php-version }}-composer-"
+
+      - name: "Install locked dependencies with composer"
+        run: "composer install --no-interaction --no-progress --no-suggest"
+
+      - name: "Create cache directory for friendsofphp/php-cs-fixer"
+        run: mkdir -p .build/php-cs-fixer
+
+      - name: "Cache cache directory for friendsofphp/php-cs-fixer"
+        uses: "actions/cache@v2"
+        with:
+          path: "~/.build/php-cs-fixer"
+          key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.sha }}"
+          restore-keys: "php-${{ matrix.php-version }}-php-cs-fixer-"
+
+      - name: "Run friendsofphp/php-cs-fixer"
+       run: "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --dry-run --verbose"

Changelog

Please have a look at CHANGELOG.md.

Contributing

Please have a look at CONTRIBUTING.md.

💡 Do you want to add a rule for personal use or use in your organization? Instead of opening a pull request here, perhaps consider creating a new package based on ergebnis/php-cs-fixer-config-template, a GitHub repository template that provides a good starting point for creating and sharing your own rule sets.

Code of Conduct

Please have a look at CODE_OF_CONDUCT.md.

License

This package is licensed using the MIT License.

Please have a look at LICENSE.md.

Credits

This project is inspired by and also replaces localheinz/php-cs-fixer-config.

Curious what I am building?

📬 Subscribe to my list, and I will occasionally send you an email to let you know what I am working on.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].