承接 gomzyakov/code-style 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gomzyakov/code-style

最新稳定版本:v2.2.0

Composer 安装命令:

composer require gomzyakov/code-style

包简介

Code style configuration for `php-cs-fixer` based on PSR-12.

README 文档

README

This package allows sharing identical php-cs-fixer formatting rules across all of your projects without copy-and-pasting configuration files.

Quickstart

Step 1 of 3

Install friendsofphp/php-cs-fixer & this package via Composer:

composer require --dev friendsofphp/php-cs-fixer gomzyakov/code-style

Step 2 of 3

Then create file .php-cs-fixer.dist.php at the root of your project with following contents:

<?php

use Gomzyakov\CodeStyleFinder;
use Gomzyakov\CodeStyleConfig;

// Routes for analysis with `php-cs-fixer`
$routes = ['./src', './tests'];

return CodeStyleConfig::createWithFinder(CodeStyleFinder::createWithRoutes($routes));

Change the value of $routes depending on where your project's source code is.

Step 3 of 3

And that's it! You can now find code style violations with following command:

./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run

And then completely fix them all with:

./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php

Configuration

You must pass a set of routes to the CodeStyleFinder::createWithRoutes() call. For example, for Laravel projects, this would be:

CodeStyleFinder::createWithRoutes(['./app', './config', './database', './routes', './tests'])

Also, you can pass a custom set of rules to the CodeStyleConfig::createWithFinder() call:

CodeStyleConfig::createWithFinder($finder, [
    '@PHP81Migration'   => true,
    'array_indentation' => false
])

Support

If you find any package errors, please, make an issue in current repository.

License

This is open-sourced software licensed under the MIT License.

Special thanks

统计信息

  • 总下载量: 1.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-05