PHP code example of gossi / php-cs-fixer-config

1. Go to this page and download the library: Download gossi/php-cs-fixer-config library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gossi / php-cs-fixer-config example snippets




$config = new phootwork\fixer\Config();
$config->getFinder()
    ->exclude(['fixture'])
    ->in(__DIR__ . '/src')
    ->in(__DIR__ . '/tests')

$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;

$config->setCacheFile($cacheDir . '/.php-cs-fixer.cache');

return $config;

vendor/
.php-cs-fixer.cache
yml
cache:
  directories:
    - $HOME/.php-cs-fixer
yml
script:
  - vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --verbose --diff --dry-run
bash
#!/usr/bin/env bash

echo "pre commit hook start"

CURRENT_DIRECTORY=`pwd`
GIT_HOOKS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

PROJECT_DIRECTORY="$GIT_HOOKS_DIR/../.."

cd $PROJECT_DIRECTORY;
PHP_CS_FIXER="vendor/bin/php-cs-fixer"

HAS_PHP_CS_FIXER=false

if [ -x "$PHP_CS_FIXER" ]; then
    HAS_PHP_CS_FIXER=true
fi

if $HAS_PHP_CS_FIXER; then
    git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | while read line; do
        ${PHP_CS_FIXER} fix --config-file=.php_cs --verbose ${line};
        git add "$line";
    done
else
    echo ""
    echo "Please install php-cs-fixer, e.g.:"
    echo ""
    echo "  composer