reisraff/phulp
Composer 安装命令:
composer require reisraff/phulp
包简介
The task manager for PHP
README 文档
README
The task manager for php
Why
Sometimes I need a tool like Gulp for my PHP projects, but I don't want to install npm only to install Gulp. I thought "I need something like Gulp, but in PHP". After a little research I found Phing, but it's not focused in minification and management for CSS/JS and related frontend stuff.
Well, I decided to write Phulp, the PHP port of Gulp! And a little curiosity: it's faster than Gulp.
PS: I made benchs using PHP 7
Documentation
Plugins
Like Gulp we also have plugins, and you also can create your own.
Available plugins you can find in the plugin section over the Phulp Page.
To make your plugin available in the Phulp plugin page, add the keyword "phulpplugin" in your composer.json file of your project, and don't forget to let a cool composer.json description.
And tag your github project with the tags "phulpplugin", and "phulp", to be searchable on github.
Usage
Install:
$ composer require --dev reisraff/phulp
Create your Phulpfile (the configuration file, that describes all your tasks):
<?php use Phulp\Output as out; // Define the default task $phulp->task('default', function ($phulp) { out::outln(out::colorize('Arguments:', 'green')); out::outln(print_r($phulp->getArguments(), true)); $phulp->start(['clean', 'iterate_src_folder', 'sync_command', 'async_command']); if ($phulp->getArgument('repeat-clean', false)) { out::outln(out::colorize('Repeating "clean"', 'green')); $phulp->start(['clean']); } }); // Define the clean task $phulp->task('clean', function ($phulp) { if (! file_exists('dist')) { mkdir('dist'); } $phulp->src(['dist/*']) ->pipe($phulp->clean()); }); // Define the iterate_src_folder task $phulp->task('iterate_src_folder', function ($phulp) { // Define the source folder $phulp->src(['src/*php']) ->pipe($phulp->iterate(function ($file) { out::outln(sprintf( '%s %s', out::colorize('Iterated ->', 'green'), out::colorize($file->getFullPath() . DIRECTORY_SEPARATOR . $file->getName(), 'blue') )); })) ->pipe($phulp->dest('dist/')); }); // Define the sync_command task $phulp->task('sync_command', function ($phulp) { $command = $phulp->exec( 'sleep 1 && echo $MSG', [ 'env' => [ 'MSG' => 'Sync-command' ], 'cwd' => '/tmp', 'sync' => true, // defines sync, 'quiet' => true, 'onStdOut' => function ($line) { out::outln($line); }, 'onStdErr' => function ($line) { }, 'onFinish' => function ($exitCode, $stdOut, $stdErr) { }, ] ); $exitCode = $command->getExitCode(); $stdout = $command->getStdout(); $stderr = $command->getStderr(); out::outln('done'); }); // Define the async_command task $phulp->task('async_command', function ($phulp) { $command = $phulp->exec( 'sleep 1 && echo $MSG', [ 'env' => [ 'MSG' => 'Async-command' ], 'cwd' => '/tmp', 'sync' => false, // defines async, 'quiet' => false, 'onStdOut' => function ($line) { }, 'onStdErr' => function ($line) { }, 'onFinish' => function ($exitCode, $stdOut, $stdErr) { }, ] ); out::outln('done'); }); // Define the watch task $phulp->task('watch', function ($phulp) { // Phulp will watch 'src' folder $phulp->watch( $phulp->src(['src/*php']), function ($phulp, $distFile) { out::outln(sprintf( '%s %s', out::colorize('File Changed ->', 'green'), out::colorize($distFile->getFullPath() . DIRECTORY_SEPARATOR . $distFile->getName(), 'blue') )); $phulp->start(['default']); } ); });
Run:
Run the phulp over the Phulpfile directory
If you have not configured the bin-dir:
$ vendor/bin/phulp --help $ vendor/bin/phulp # Will run the `default` task $ vendor/bin/phulp --arg=repeat-clean:true # Will run the `default` task with the argument repeat-clean with value `true` $ vendor/bin/phulp --autoload=/my/autoload/path/autoload.php # Will run the `default` task adding a alternative autoload php file $ vendor/bin/phulp watch # Will run the `watch` task
The full documentation:
Example:
https://github.com/reisraff/phulp/blob/master/example/phulpfile.php
Run the example file:
$ composer install
$ cd example
$ ../bin/phulp
$ ../bin/phulp watch
Contributors Guide
Clone
$ git clone git@github.com:reisraff/phulp.git
$ cd phulp
$ composer install
Tests
First install the dependencies, and after you can run:
$ bin/phulp test
TODO
The "Issues" page from this repository is being used for TO-DO management.
Credits
reisraff/phulp 适用场景与选型建议
reisraff/phulp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.21k 次下载、GitHub Stars 达 293, 最近一次更新时间为 2016 年 05 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「task」 「builder」 「watcher」 「gulp」 「task-runner」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 reisraff/phulp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 reisraff/phulp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 reisraff/phulp 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Expose the DDev executable commands to the Robo task runner.
A Sphinx Query Builder extension for the Laravel Database package
Anax Database Active Record module for model classes.
A simple package to create tables in Discord messages.
Task system for APPUI
Create mail from controller action render
统计信息
- 总下载量: 12.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 294
- 点击次数: 15
- 依赖项目数: 10
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-05-18
