dev-master
9999999-devPHP Task Runner
MIT
The Requires
- php >=5.4
- matthiasmullie/minify dev-master
- symfony/console ~2
- symfony/filesystem ~2
- symfony/finder ~2
The Development Requires
task runner
PHP Task Runner
I know you love Grunt and Gulp when it comes to automate tedious tasks such as minifying CSS and JS, resizing images... Everybody does., (*1)
But are you allergic to NPM as I am?, (*2)
Are you fed up with having to download nearly half the Internet when you just want to minify a bunch of files?, (*3)
Beverage is there for you: pure PHP- and Composer-powered task runner for your projects., (*4)
As easy to use as Gulp, minus the NPM dependencies chaos. If you know Gulp, you already master Beverage., (*5)
Add this to your composer.json file:, (*6)
{ "require": { "awakenweb/beverage": "dev-master" } }
Have a look at the Modules page, (*7)
First, create a drinkmenu.php
file at the root of your project. You can create a boilerplate file by running the vendor/bin/beverage beverage:init
command., (*8)
This file will contain the different tasks you will want to run., (*9)
This file must at least contain a defaultTask()
function that will be triggered when calling the beverage command if no specific task is called., (*10)
Here is a demo drinkmenu.php
:, (*11)
<?php use Awakenweb\Beverage\Beverage; use Awakenweb\Beverage\Modules\Css; use Awakenweb\Beverage\Modules\Js; function defaultTask() { minifyCss(); minifyJs(); } function minifyCss() { Beverage::files('*.css', ['css']) ->then(new Css()) ->destination('build/css'); } function minifyJs() { Beverage::files('*.js', ['js']) ->then(new Js()) ->destination('build/js'); }
For a more complete demo file, run vendor/bin/beverage beverage:init
, (*12)
You can now run the command by calling vendor/bin/beverage
, (*13)
Every command can be called by shorthand: vendor/bin/beverage b:i
will have the same effect as vendor/bin/beverage beverage:init
., (*14)
You can use the --drinkmenu
option to specify where to find the drinkmenu.php file, or if you renamed it., (*15)
You can define a file watcher to automatically run tasks on recently modified files., (*16)
You need to import the Awakenweb\Beverage\Watcher
module in your drinkmenu.php
and create a dedicated watch()
task., (*17)
function watch($output) { (new Watcher($output)) ->beforeTasks(new RandomListener()) ->afterTasks(new AnotherRandomListener()) ->watch('*.scss', ['compileScssAndMinifyCss'], ['scss']) ->run(); }
The beforeTasks
and afterTasks
methods allow you to register hooks that will be triggered before and after your tasks when the files are changed., (*18)
These hooks must implement the Awakenweb\Beverage\Watcher
Listenerthat only needs a
update()` method., (*19)
By allowing a $output parameter, you give the watcher a way to tell you when a task is triggered and when it's done., (*20)
You can either launch the watcher as any other task (vendor/bin/beverage beverage:run watch
) or with the special task dedicated to watching files: vendor/bin/beverage beverage:watch
, (*21)
Bugs, (*22)
If you found a bug and feel confident enough to correct it, please send a pull request with your bugfix and a unit test to identify the bug., (*23)
If you can't correct the bug by yourself, please fill an issue on this Github repository., (*24)
Security vulnerabilities, (*25)
New Features, (*26)
Before sending a Pull Request for a new feature you want to add directly to the Beverage codebase, please contact Mathieu SAVELLI by email. If the feature is found to be a good fit for Beverage, you are free to make a pull request., (*27)
If you like this package, the best thing you can do is to provide new awesome modules for Beverage and notify me. I'll add them to this readme., (*28)
Beverage is released under the MIT License, (*29)
PHP Task Runner
MIT
task runner