This Yeoman generator will quickly and easily scaffold a PHP package, getting you up and running within a few seconds.
It will generate the necessary files such as a source folder, composer.json etc
For a full overview of the scaffolded files, have a look over here.
If you haven't done so already, install the Yeoman generator:
npm install -g yo
After that, install the scaffolder generator:
npm install -g generator-php-package-scaffolder
Run the following command:
yo php-package-scaffolder
and follow the instructions.
Given a package with the name "MyPackage", the resulting package will have the following directory structure and files:
.
├── README.md
├── .gitignore
├── composer.json
├── phpunit.xml
├── src
│ ├── MyPackage.php
└── tests
└── MyPackageTest.php
If you want to use your package on the local filesystem in a PHP app for development purposes, include the package in the app's composer.json file:
"repositories": [
{
"type": "path",
"url": "path/to/your/package/root"
}
],
Next, add your package to the require section of the app's composer.json file:
"require": {
"vendor/package": "*"
}
After the composer.json file has been updated, run the composer update command:
composer update
This will symlink the package into the app's vendor dir.
Note: If you update your package's composer.json file, you need to run the composer update command again to update the app's autoloader.
This is only necessary for the composer.json file. Changes in any other files in your package will be automatically updated thanks to the symlink.
See CONTRIBUTING.md.
See CHANGELOG.md.
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
The generator is fully backed (well, almost fully backed 😐) by unit tests. The test runner of choice is Jest.
jest
jest --coverage --coverageDirectory=coverage/jest