定制 wouterj/fred 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wouterj/fred

最新稳定版本:0.3.0

Composer 安装命令:

composer require wouterj/fred

包简介

A very simple iteration based task runner

README 文档

README

Welcome to Fred. Fred will execute tasks that you have described in a fred file.

Fred is not a grown up man at the moment. The steps used in this docs are not yet implemented. Do you help me teach him how to do developer tasks?

Build Status

Why should I use Fred?

  • You don't have to spent time installing NodeJS, NPM on your server just to run tasks;
  • You can work with a syntax you're familiar with;
  • Fred's codebase is very small (just 9 classes) and as flexible as task runners can be.

Installation

The best way to install Fred is using Composer:

$ composer global require wouterj/fred:0.*

If you set-up composer's global binary directory correctly, this will give you a new command: fred

Usage

You start by creating a fred.php file (the fred file). In this file, you specify the tasks. You do this by calling the task() method of the $fred variable that's available in the file:

$fred->task('build', function () use ($fred) {
    // ... specify the tasks
});

All tasks begin by opening a file or multiple files and passing a Traversable of these files to load(). The best way to do this is by using the Symfony Finder Component:

use Symfony\Component\Finder\Finder;

$fred->task('build', function () use ($fred) {
    $fred->load(Finder::create()->files()->name('*.js')->in('/web/assets/raw'));
});

You've now opened a Fred step sequence for all files with a .js extension in /web/assets/raw.

Now you can assign as many steps to this sequence as you want:

use Symfony\Component\Finder\Finder;
use WouterJ\Fred\Extension as Ext;

$fred->task('build', function () use ($fred) {
    $fred->load(Finder::create()->files()->name('*.js')->in('/web/assets/raw'))
        ->then(new Ext\JsHint())   // Lint the JS code using JsHint...
        ->then(new Ext\Uglify())   // ...minify the JS files using UglifyJS...
        ->then(new Ext\Compact())  // ...and combine all JS files into one file
    ;
});

At last, you have to output the generated code somewhere. This is done with the dist() function:

$fred->load(Finder::create()->files()->name('*.js')->in('/web/assets/raw'))
    ->then(new Ext\JsHint())
    ->then(new Ext\Uglify())
    ->then(new Ext\Compact())
    ->dist('/web/assets/script.min.js')
;

Now, the generated code is dumped in the /web/assets/script.min.js file.

You can run this task by using fred build (where build is the name of the task).

License

The project is released under the BSD license. See the LICENSE file included in this package for more information.

Roadmap

Of course, all kind of changes are welcome (as long as it doesn't make the Fred more complex), but Fred should have learn the following things before reaching a stable version:

  • Have more tests (that actually test the console app)
  • Have a complete documentation
  • Have more extensions and steps

统计信息

  • 总下载量: 25
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 26
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 7
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: BSD
  • 更新时间: 2014-12-30