Skip to content

verschuur/generator-php-package-scaffolder

Repository files navigation

Yeoman PHP Package Generator

Maintainability Scrutinizer Travis (.org)

What's this about then

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.

Installation

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

Using the generator

Run the following command:

yo php-package-scaffolder

and follow the instructions.

The resulting scaffolded package

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

Using the package

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.

Contributing

See CONTRIBUTING.md.

Changelog

See CHANGELOG.md.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Testing

The generator is fully backed (well, almost fully backed 😐) by unit tests. The test runner of choice is Jest.

Running Tests

jest

Generating code coverage

jest --coverage --coverageDirectory=coverage/jest

About

A Yeoman generator to quickly scaffold a PHP package.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •