A generator for Yeoman to generate boilerplate for a PHP library with support for PHPUnit.
- Make sure you have yo installed:
npm install -g yo - Install the generator:
npm install -g generator-php-library - Run:
yo php-library
The generator will automatically create the following boilerplate for you:
- creates correctly namespaced folder structure for your library:
/srcfolder structure for your PHP code/testsfolder structure for your PHPUnit unit tests
- installs and configures PHPUnit:
- installs PHPUnit using composer
- creates a
phpunit.xmlandBootstrap.phpfile for PHPUnit - creates GruntJS configuration for running PHPUnit using GruntJS
- creates a sample unit test file
SampleTest.php
- creates configuration files:
composer.jsonwith autoloader support for your librarypackage.jsonwith the right dependencies to lint and unit test your codeGruntfile.jswith the configuration to lint and unit test your code
- generates an autoloader for your library using composer
Add your library classes in the namespaced directories in the /src directory.
Add your unit tests in the namespaced directories in the /tests directory.
Run grunt to lint your PHP code and run your unit tests:
grunt
- First public release
- Added GruntJS support for linting PHP using the grunt-phplint plugin
- Added GruntJS support for unit testing using the grunt-phpunit plugin
- Added GruntJS support for PHP Code Sniffer using the grunt-phpcs plugin
- Added basic
.gitignore - Spoecial thanks to @melindrea for providing the idea to include GruntJS support