Download the PHP package brightnucleus/boilerplate without Composer
On this page you can find all versions of the php package brightnucleus/boilerplate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brightnucleus/boilerplate
More information about brightnucleus/boilerplate
Files in brightnucleus/boilerplate
Package boilerplate
Short Description Boilerplate package you can use to quickly create a new package from scratch.
License MIT
Informations about the package boilerplate
Bright Nucleus Boilerplate
Boilerplate package you can use to quickly create a new package from scratch.
Table Of Contents
- Basic Usage
- Customizing The Generated Boilerplate
- Providing A Custom Config File
- Changing The Templates
- Changing The Placeholders
- Adding A Custom Setup Task
- Contributing
- License
Basic Usage
To create a new package using composer, use the following command:
This will create a new folder called <package-folder>
, clone the brightnucleus/boilerplate
package into that folder, and run the setup scripts. These scripts will ask you several questions about the package you want to create.
Customizing The Generated Boilerplate
If you want to use this package for your own purposes, you can either fork it and adapt the workflow and templates with some simple tweaks, or you can require it through Composer to extend it.
Providing A Custom Config File
You can set the configuration file to be loaded through the "extra"
key in the composer.json
file:
If you want to modify the key that is used for this ("brightnucleus-boilerplate"
), you can override the Setup::getExtraKey()
method.
Changing The Templates
The templates can be found in the _templates
folder and can have an optional .template
extension. Each template in that folder will be copied to the root folder, after it has been run through a Mustache renderer that replaces all the placeholders with the actual values you've provided during the script execution.
If there are subfolders within _templates
, these subfolders and their content will also be mirrored within the root folder. So, you can build the entire file structure that will later land in your package root folder within this _templates
folder.
Adding a new template is just a matter of adding a new file within that structure.
Changing The Placeholders
The placeholders are defined within the _config/defaults.php
file.
To add a new placeholder, you can just add a new element to the array referenced by BrightNucleus/Boilerplate/Placeholders
.
Example:
This example will add a new placeholder {{greeting}}
that you can use within your templates.
The validation value passed to 'validation'
needs to be a callable that gets the current value entered by the user, and needs to either return the validated form of that value, or throw an exception if the value does not meet the requirements. The Validation
class provides some helper methods to do the actual validation.
The default value passed into 'default'
can be either a literal value to use, or a callable that gets the array of placeholders as an argument, and needs to return a value to use. Using this array, you can make one default value depend on the current value of another placeholder, provided that that placeholder has already been set before (ordering within the config file).
Adding A Custom Setup Task
The individual tasks are simple classes that implement the BrightNucleus\Boilerplate\Scripts\SetupTask
interface:
In most cases, it is probably preferable to extend BrightNucleus\Boilerplate\Scripts\Task\AbstractTask
though, as this provides some convenience functionality.
Here's an example task that displays a "Boilerplate" logo in the console:
Now, to hook this task up to the setup process, you insert the class name into the getSetupTasks()
method of the BrightNucleus\Boilerplate\Scripts\Setup
class.
The array of classes is executed in the order in which the classes have been added, so if we want to display our new logo as the very first step to be taken, we insert it at the top of the array.
If we now run our composer create-project
command, Composer will first download everything it needs, then start the custom setup process by displaying the new logo first.
Contributing
All feedback / bug reports / pull requests are welcome.
License
Copyright (c) 2016 Alain Schlesser, Bright Nucleus
This code is licensed under the MIT License.
All versions of boilerplate with dependencies
brightnucleus/config Version >=0.4
composer/composer Version ^1.1
symfony/finder Version ^3.1
mustache/mustache Version ^2.10