定制 leviy/coding-standard 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

leviy/coding-standard

最新稳定版本:v4.0.6

Composer 安装命令:

composer require leviy/coding-standard

包简介

LEVIY Coding Standard

README 文档

README

Leviy logo

Leviy Coding Standard

Build status Packagist version PHP from Packagist

The Leviy coding standard for PHP code, with rulesets for PHP CodeSniffer and PHP Mess Detector.

Installation

Install this package using Composer:

composer require --dev leviy/coding-standard

Installing the PHP CodeSniffer ruleset

Create a file phpcs.xml in the root of the project with the following contents:

<?xml version="1.0" encoding="UTF-8"?> <ruleset> <rule ref="LEVIY"/> <config name="ignore_warnings_on_exit" value="1"/> <arg name="extensions" value="php"/> <file>src/</file> <file>tests/</file> <file>public/index.php</file> </ruleset>

Installing the PHP Mess Detector ruleset

Create a file phpmd.xml in the root of the project with the following contents:

<?xml version="1.0" encoding="UTF-8"?> <ruleset xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" name="Mess detector ruleset"> <description>Ruleset for PHP Mess Detector that enforces coding standards</description> <rule ref="vendor/leviy/coding-standard/phpmd.xml"/> </ruleset>

Configuration

PHP CodeSniffer

An annotated ruleset.xml configuration file can be found here where you can see the complete range of features and configuration options that can be used to modify the configuration to your project needs.

PHP Mess Detector

Documentation about tweaking the ruleset and exluding rules or changing settings can be found here.

Usage

Run vendor/bin/phpcs to run PHP CodeSniffer. If you have a file phpcs.xml or phpcs.xml.dist in root directory of the project, CodeSniffer will use it automatically. Add a path to run CodeSniffer only against that file or directory. See Usage for more detailed usage instructions.

Run vendor/bin/phpmd src/ text phpmd.xml to run PHP Mess Detector against the src directory and print a report in the "text" format.

PHPStorm code sniffer validation

  1. Open "Preferences" and navigate to "Editor > Inspections".

  2. Enable "PHP > Quality tools > PHP_Code Sniffer validation".

  3. Select a "Custom" coding standard.

  4. Select the path to the projects code sniffer configuration.

Enjoy the immediate feedback of code sniffer validation issues!

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 5
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固