Yeoman generator or creating a package.json and Gruntfile.js with relevant tools and questions for a Yii project.
I adapted my own Yii Gruntfile which carries out tasks such as PHP static analysis of your Yii code, CSS linting and JS linting specific to the layout of a Yii project.
Be sure to run these in your web root folder.
npm install generator-gruntfile-yii
You'll be asked a series of questions to help setup your Gruntfile and package.json before it goes and creates it for you.
This will install the
package.json into your web directory. The same directory that contains the "protected" and "assets" directories. Then
npm install will install all the required node modules. Be sure to have the prerequisites below as it will expect them.
Depending on your answers in the generator you may need the following:
- PHP Code Sniffer
- PHP Mess Detector
- PHP Copy/Paste Detector
- PHP CS Fixer
- To run the
grunt phpserver task you'd need PHP >=5.4 but its not compulsory.
In your Yii root folder (the one containing index.php and
protected folder) run this command:
grunt -hshow tasks
gruntrun all tasks
grunt phpcsrun phpcs tool on all compnents, controller & models
grunt phpcs:modelsas above but only on models
grunt phpmdrun PHP Mess Detector on all compnents, controller & models
- Many more - check the grunt file and feel free to edit to your needs.
This is my first generator - please report any bugs or issues you find All are very welcome and I'm very happy for you to submit bug reports, feature requesats and even better - pull requests.