2017 © Pedro Peláez
 

library beverage

PHP Task Runner

image

awakenweb/beverage

PHP Task Runner

  • Friday, February 20, 2015
  • by awakenweb
  • Repository
  • 2 Watchers
  • 4 Stars
  • 36 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

This package is not maintained anymore, a fun mini project keeped as archive only

Beverage

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)

Prerequisites

Install

Add this to your composer.json file:, (*6)

{
    "require": {
        "awakenweb/beverage": "dev-master"
    }
}

Modules

Have a look at the Modules page, (*7)

Configuration

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)

Options

You can use the --drinkmenu option to specify where to find the drinkmenu.php file, or if you renamed it., (*15)

File Watcher

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\WatcherListenerthat only needs aupdate()` 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)

Contributing

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)

  • If you think you found a security vulnerability in this package, please contact Mathieu SAVELLI by email before doing anything else.

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)

Contributors

  • Main developer: __Mathieu SAVELLI__ (_mathieu.savelli@awakenweb.fr_)

License

Beverage is released under the MIT License, (*29)

The Versions

20/02 2015

dev-master

9999999-dev

PHP Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

task runner