承接 nette/coding-standard 相关项目开发

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

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

nette/coding-standard

Composer 安装命令:

composer require nette/coding-standard

包简介

README 文档

README

Downloads this Month Latest Stable Version License

Introduction

Nette Coding Standard checks and automatically fixes your PHP code so that it follows the Nette coding standard – from indentation and braces to spacing and the ordering of imports.

Under the hood it combines two industry-standard tools, PHP CS Fixer and PHP_CodeSniffer, preconfigured with the full Nette rule set, so you don't have to configure anything yourself. It also ships rules for the latest PHP versions and applies them incrementally based on the PHP version your project uses.

It runs as a standalone application, not as a project dependency, which keeps its many dependencies away from your own.

Documentation can be found on the website. If you like it, please make a donation now. Thank you!

Installation

Install it globally via Composer:

composer global require nette/coding-standard

Make sure your global Composer bin directory is in your PATH. The ecs command is then available from anywhere, on any operating system.

Alternatively, install it as a standalone project, which is handy for pinning a specific version in CI:

composer create-project nette/coding-standard

It requires PHP 8.0 or higher.

Usage

The tool provides two commands. The check command runs in read-only mode and only reports violations, while fix repairs them automatically:

ecs check
ecs fix

Without any arguments it scans the src and tests directories. You can also pass one or more of your own paths:

ecs check app bin

Back up your files first, or run fix on a clean working tree so you can review the changes afterwards with git diff.

In read-only mode the tool exits with a non-zero code when any violation is found, so it fits nicely into CI pipelines.

PHP Version

The tool supports PHP 8.0 to 8.5 and applies the rules incrementally according to the version. The version preset is detected automatically from your project's composer.json. If auto-detection is not possible, specify it manually:

ecs check --preset php81

Custom Configuration

You can tweak the rules per-project by placing ncs.php (PHP CS Fixer) and/or ncs.xml (PHP_CodeSniffer) in your project root. Both are discovered automatically and merged on top of the preset, with your values taking precedence.

ncs.php returns an associative array of fixer overrides:

<?php
return [
	'strict_comparison' => false,
	'PhpCsFixerCustomFixers/commented_out_function' => false, // don't comment out dump(), var_dump(), ...
];

ncs.xml is a PHP_CodeSniffer ruleset. It does not need to reference the version preset – that is added automatically – and you can use $presets/ to pull in any bundled preset:

<?xml version="1.0"?>
<ruleset name="MyProject">
	<!-- enable grouped `use function`/`use const` imports -->
	<rule ref="$presets/optimize-fn.xml"/>

	<!-- disable a rule -->
	<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint"/>

	<!-- override a rule's property -->
	<rule ref="NetteCodingStandard.WhiteSpace.FunctionSpacing">
		<properties>
			<property name="spacing" value="1"/>
		</properties>
	</rule>
</ruleset>

Ad-hoc Configuration via --config-file

For one-off runs (e.g. when you want to keep dump() calls intact during debugging) you can point to an additional config file without committing it to the project:

ecs fix src --config-file ./my-overrides.php

The tool is selected by extension: .php applies to PHP CS Fixer, .xml to PHP_CodeSniffer. You can pass --config-file twice to configure both tools. Project-level ncs.php/ncs.xml are still used; values from --config-file take precedence.

GitHub Actions

In a CI pipeline, install the tool as a project and run it from there:

# .github/workflows/coding-style.yml
steps:
    - uses: actions/checkout@v4
    - uses: shivammathur/setup-php@v2
      with:
          php-version: 8.1

    - run: composer create-project nette/coding-standard temp/coding-standard
    - run: php temp/coding-standard/ecs check

nette/coding-standard 适用场景与选型建议

nette/coding-standard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 937.63k 次下载、GitHub Stars 达 41, 最近一次更新时间为 2017 年 06 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nette/coding-standard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nette/coding-standard 我们能提供哪些服务?
定制开发 / 二次开发

基于 nette/coding-standard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 937.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 41
  • 点击次数: 11
  • 依赖项目数: 17
  • 推荐数: 0

GitHub 信息

  • Stars: 41
  • Watchers: 10
  • Forks: 13
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-04