如何让php cs fixer为Symfony项目工作?

如何让php cs fixer为Symfony项目工作?,php,symfony,php-cs-fixer,Php,Symfony,Php Cs Fixer,我通过运行 $ wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer $ sudo chmod a+x php-cs-fixer $ sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer 接着是跑步 $ wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer

我通过运行

$ wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer
$ sudo chmod a+x php-cs-fixer
$ sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
接着是跑步

$ wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer
$ sudo chmod a+x php-cs-fixer
$ sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
当我尝试用

$ php-cs-fixer -vv fix /home/xxx/host/master/src/AppBundle/Command/GenerateERPContractInvoicesCommand.php --config=sf2
这将导致以下错误消息:

[PhpCsFixer\ConfigurationException\InvalidConfigurationException(16)]
无法读取配置文件“sf2”

尝试使用
--config=sf23
运行会导致相同的错误消息

想这样跑吗

$ php-cs-fixer fix src/AppBundle/Command/GenerateERPContractInvoicesCommand.php --level=symfony 
结果显示错误消息

“--level”选项不存在

然后我创建一个配置文件
.php\u cs
,其中包含

<?php

$finder = Symfony\CS\Finder::create()
    ->exclude([
        'app', 
        'spec', 
        'build', 
        'bin', 
        'web', 
        'vendor',
    ])
    ->in(__DIR__);

return Symfony\CS\Config::create()
    ->fixers([
        'short_array_syntax', 
        '-phpdoc_align',
        'ordered_use',
    ])
    ->finder($finder);

根据文档,您可能希望使用
规则运行
参数:

php php-cs-fixer.phar fix /path/to/project --rules=@Symfony

我在ci开发版本中使用以下命令:

php-cs-fixer-fix——使用cache=no——rules=@Symfony-src

问题在于,您正在完成所有工作(cli参数、配置文件),就像PHP CS Fixer v1一样,但您正在下载v2。 如果您想知道如何迁移,请查看升级指南: