PHP code example of prooph / php-cs-fixer-config
1. Go to this page and download the library: Download prooph/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/ */
prooph / php-cs-fixer-config example snippets
$config = new Prooph\CS\Config\Prooph();
$config->getFinder()->in(__DIR__);
$config->getFinder()->append(['.php-cs-fixer.php']);
$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.cache
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-fixer.php --verbose ${line};
git add "$line";
done
else
echo ""
echo "Please install php-cs-fixer, e.g.:"
echo ""
echo " composer