greynoise-design/laravel-coding-standard 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

greynoise-design/laravel-coding-standard

最新稳定版本:1.0.2

Composer 安装命令:

composer require greynoise-design/laravel-coding-standard

包简介

Laravel 5 Coding Standard for PHP_CodeSniffer 3.

README 文档

README

Version 1.0.2

Master Develop
Build Status Build Status
Coverage Status Coverage Status

Requirements

PHP_CodeSniffer 3. (3.1.1 or greater).

Global install (Recommended)

Globally install PHP_CodeSniffer with one of the various methods. (Skip this step if you already have it installed.)

Once complete you should be able to execute phpcs -i on the command line.

You should see something like:-

The installed coding standards are MySource, PEAR, PSR1, PSR2, Squiz and Zend.

(Recommended) use composer...

composer global require greynoise-design/laravel-coding-standard

or clone this repository...

git clone -b master --depth 1 https://github.com/greynoise-design/laravel-coding-standard.git.

or download.

Take note of the paths where they were installed.

(Recommended) Create a symbolic link to the 'laravel-coding-standard/GreynoiseLaravel' directory in 'php_codesniffer/src/Standards/' eg.

ln -s ~/Documents/Projects/laravel-coding-standard/GreynoiseLaravel ~/.composer/vendor/squizlabs/php_codesniffer/src/Standards/GreynoiseLaravel

or copy the GreynoiseLaravel directory to php_codesniffer/src/Standards/

Executing phpcs -i should now show GreynoiseLaravel installed eg.

The installed coding standards are GreynoiseLaravel, MySource, PEAR, PSR1, PSR2, Squiz and Zend.

You should now be able to set 'GreynoiseLaravel' as the phpcs standard in the plugin/editor/IDE of your choice.

Composer install for a single project

cd /Path/To/MyProject

composer require greynoise-design/laravel-coding-standard

Set the 'phpcs standard path' and 'phpcbf standard path' in your editor/plugin config to:

'/Path/To/MyProject/vendor/laravel-coding-standard/GreynoiseLaravel/ruleset.xml'

Command line use

Sniffing errors & warnings (reporting).

Single file...

phpcs /Path/To/MyFile.php --standard='/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml'

or if globally installed.

phpcs /Path/To/MyFile.php --standard=GreynoiseLaravel

Directory (recursive).

phpcs /Path/To/MyProject --standard='/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml'

or if globally installed.

phpcs /Path/To/MyProject --standard=GreynoiseLaravel

Fixing fixable errors.

Single file.

phpcbf /Path/To/MyFile.php --standard='/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml'

or if globally installed.

phpcbf /Path/To/MyFile.php --standard=GreynoiseLaravel

Directory (recursive).

phpcbf /Path/To/MyProject --standard='/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml'

or if globally installed.

phpcbf /Path/To/MyProject --standard=GreynoiseLaravel

Example editor configs

SublimeText project config

Project > Edit Project

Set it to your preference.

{
    "SublimeLinter":
    {
        "linters":
        {
            "phpcs":
            {
                "@disable": false,
                "cmd": "/Path/To/php_codesniffer/bin/phpcs",
                // Or if installed globally. "cmd": "phpcs",
                "standard": "/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml",
                // Exclude folders and files in the linting environment.
                // (Matches exclude-patterns in ruleser.xml).
                "excludes":
                [
                    "*/config/*",
                    "*/cache/*",
                    "*/database/*",
                    "*/docs/*",
                    "*/migrations/*",
                    "*/public/index.php",
                    "*/vendor/*",
                    "*/storage/*",
                    "*/*.blade.php",
                    "*/*.css",
                    "*/*.js",
                    "*/*.xml",
                    "*/autoload.php",
                    "*/Middleware/*",
                    "*/Console/Kernel.php",
                    "*/Exceptions/Handler.php",
                    "*/Http/Kernel.php",
                    "*/Providers/*"
                ],
            }
        }
    },
    "folders":
    [
        {
            "path": "/Path/To/MyProject"
        }
    ],
    "settings":
    {
        "phpcs":
        {
            "extensions_to_execute":
            [
                "php"
            ],
            "phpcs_executable_path": "/Path/To/php_codesniffer/bin/phpcs",
            // Or if installed globally. "phpcbf_executable_path": "phpcs",
            "phpcs_additional_args":
            {
                "--standard": "/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml",
                // Optional don't show warnings
                // "-n": ""
            },
            "phpcbf_executable_path": "/Path/To/php_codesniffer/bin/phpcbf",
            // Or if installed globally. "phpcbf_executable_path": "phpcbf",
            "phpcbf_additional_args":
            {
                "--standard": "/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml",
                // Optional don't fix warnings (if they're fixable)
                // "-n": ""
            },
            // Execute the sniffer on file save. (Using contextual menu instead)
            "phpcs_execute_on_save": false,
            // Show the error list after save. (Using sublime linter instead)
            "phpcs_show_errors_on_save": false,
            // Show the errors in the quick panel so you can then goto line. (Gets annoying)
            "phpcs_show_quick_panel": false,
            // Turn the debug output on/off.
            "show_debug": false
        }
    }
}

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固