2017 © Pedro Peláez
 

library laravel-coding-standard

Laravel 5 Coding Standard for PHP_CodeSniffer 3.

image

greynoise-design/laravel-coding-standard

Laravel 5 Coding Standard for PHP_CodeSniffer 3.

  • Monday, December 11, 2017
  • by louisl
  • Repository
  • 0 Watchers
  • 3 Stars
  • 281 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 56 % Grown

The README.md

Greynoise Design - Laravel 5 Standard

Version 1.0.2, (*1)

Master Develop
Build Status Build Status
Coverage Status Coverage Status

Requirements

PHP_CodeSniffer 3. (3.1.1 or greater)., (*2)

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

Once complete you should be able to execute phpcs -i on the command line., (*4)

You should see something like:-, (*5)

The installed coding standards are MySource, PEAR, PSR1, PSR2, Squiz and Zend., (*6)

(Recommended) use composer..., (*7)

composer global require greynoise-design/laravel-coding-standard, (*8)

or clone this repository..., (*9)

git clone -b master --depth 1 https://github.com/greynoise-design/laravel-coding-standard.git., (*10)

or download., (*11)

Take note of the paths where they were installed., (*12)

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

ln -s ~/Documents/Projects/laravel-coding-standard/GreynoiseLaravel ~/.composer/vendor/squizlabs/php_codesniffer/src/Standards/GreynoiseLaravel, (*14)

or copy the GreynoiseLaravel directory to php_codesniffer/src/Standards/, (*15)

Executing phpcs -i should now show GreynoiseLaravel installed eg., (*16)

The installed coding standards are GreynoiseLaravel, MySource, PEAR, PSR1, PSR2, Squiz and Zend., (*17)

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

Composer install for a single project

cd /Path/To/MyProject, (*19)

composer require greynoise-design/laravel-coding-standard, (*20)

Set the 'phpcs standard path' and 'phpcbf standard path' in your editor/plugin config to:, (*21)

'/Path/To/MyProject/vendor/laravel-coding-standard/GreynoiseLaravel/ruleset.xml', (*22)

Command line use

Sniffing errors & warnings (reporting).

Single file..., (*23)

phpcs /Path/To/MyFile.php --standard='/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml', (*24)

or if globally installed., (*25)

phpcs /Path/To/MyFile.php --standard=GreynoiseLaravel, (*26)

Directory (recursive)., (*27)

phpcs /Path/To/MyProject --standard='/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml', (*28)

or if globally installed., (*29)

phpcs /Path/To/MyProject --standard=GreynoiseLaravel, (*30)

Fixing fixable errors.

Single file., (*31)

phpcbf /Path/To/MyFile.php --standard='/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml', (*32)

or if globally installed., (*33)

phpcbf /Path/To/MyFile.php --standard=GreynoiseLaravel, (*34)

Directory (recursive)., (*35)

phpcbf /Path/To/MyProject --standard='/Path/To/laravel-coding-standard/GreynoiseLaravel/ruleset.xml', (*36)

or if globally installed., (*37)

phpcbf /Path/To/MyProject --standard=GreynoiseLaravel, (*38)

Example editor configs

SublimeText project config

Project > Edit Project, (*39)

Set it to your preference., (*40)

{
    "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
        }
    }
}

The Versions

11/12 2017

dev-feature/unit-test

dev-feature/unit-test

Laravel 5 Coding Standard for PHP_CodeSniffer 3.

  Sources   Download

MIT

The Development Requires

08/12 2017

dev-master

9999999-dev

Laravel 5 Coding Standard for PHP_CodeSniffer 3.

  Sources   Download

MIT

The Development Requires

08/12 2017

1.0.2

1.0.2.0

Laravel 5 Coding Standard for PHP_CodeSniffer 3.

  Sources   Download

MIT

The Development Requires

08/12 2017

dev-develop

dev-develop

Laravel 5 Coding Standard for PHP_CodeSniffer 3.

  Sources   Download

MIT

The Development Requires

07/12 2017

1.0.1

1.0.1.0

Laravel 5 Coding Standard for PHP_CodeSniffer 3.

  Sources   Download

MIT

The Development Requires

07/12 2017

1.0.0

1.0.0.0

Laravel 5 Coding Standard for PHP_CodeSniffer 3.

  Sources   Download

MIT

The Development Requires