Giter Club home page Giter Club logo

Comments (2)

larryli avatar larryli commented on May 23, 2024

You can add yiisoft/yii2-coding-standards on composer.json:

    "require-dev": {
        "yiisoft/yii2-debug": "*",
        "yiisoft/yii2-gii": "*",
        "yiisoft/yii2-coding-standards": "2.*"
    }

Next, create a phpcs.xml.dist file on the project root directory, see PHP_CodeSniffer Documentation: Using a Default Configuration File

<?xml version="1.0"?>
<ruleset name="Yii2 App Basic Standard">
    <description>Yii2 App Basic coding standard</description>

    <exclude-pattern>/runtime/*</exclude-pattern>
    <exclude-pattern>/web/assets/*</exclude-pattern>
    <exclude-pattern>/vendor/*</exclude-pattern>
    <exclude-pattern>/requirements.php</exclude-pattern>

    <rule ref="vendor/yiisoft/yii2-coding-standards/Yii2"/>

    <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
        <exclude-pattern>/migrations/*</exclude-pattern>
    </rule>
    <rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
        <exclude-pattern>/migrations/*</exclude-pattern>
    </rule>
</ruleset>

Last, use command:

php composer.phar install --dev
vendor/bin/phpcs --encoding=utf-8 --extensions=php .

from yii2-coding-standards.

bubifengyun avatar bubifengyun commented on May 23, 2024

Thank you, i had solved this problem. I used XAMPP, and set

sudo ln -s /opt/lampp/bin/php /usr/local/bin/php
sudo ln -s /opt/lampp/bin/pear /usr/local/bin/pear

installed the PHP_CodeSniffer, and find the folder /opt/lampp/lib/php/PHP/CodeSniffer/Standards/

So, I copy Yii2 folder from this project to the above folder. That is

/opt/lampp/lib/php/PHP/CodeSniffer/Standards
  Yii2/{ruleset.xml,Sniffs}
  PSR2
  <many standards>

Then, Yii2 can be used like PSR2 and Zend.
Thank you.

from yii2-coding-standards.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.