定制 molovo/phake 二次开发

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

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

molovo/phake

Composer 安装命令:

composer require molovo/phake

包简介

A PHP task runner inspired by Make, Rake et al.

关键字:

README 文档

README

Join the chat at https://gitter.im/molovo/phake

A PHP task runner inspired by Make, Rake et al.

Installation and Usage

Installing phake globally

composer global require molovo/phake

# Ensure ~/.composer/vendor/bin is in your path, then in a directory
# with a Phakefile, run:
phake task

Installing per Project:

composer require molovo/phake

vendor/bin/phake task

Installing ZSH Completion

Rename the file phake.zsh-completion to _phake, and move it somewhere in your $fpath. /usr/local/share/zsh/site-functions/ is usually a good choice.

Usage

Default Task

Create a file called Phakefile in the root of your project. This is just a simple PHP file. The first task you should define is called default. This is the task that is performed if you run phake without any arguments.

For now, we'll use it to execute a simple shell command by passing it a string:

<?php

task('default', 'echo "Hello World!"');

Now you can run phake in the same directory as your Phakefile, and you will see Hello World! printed to the console.

Naming tasks

The first parameter is the name of the task.

<?php

task('my_awesome_task', 'echo "Doing awesome things..."');

To run that task, run phake my_awesome_task.

Multiple commands

Most tasks in phake will perform more than one simple shell command. To do that, pass an array of commands as the second parameter.

<?php

task('test', [
  'echo "Starting Tests"',
  './my_tests.sh',
  'echo "Tests finished."'
]);

Using closures

Tasks can also contain a PHP closure, so that you can include PHP logic in your tasks. Phake uses Composer for autoloading, so that your entire project's PHP code is available to you.

<?php

task('php_example', function () {
  my_php_function(); // Your PHP code is available here
});

Running other tasks

If you use the PHP callback method, you can call other tasks from within your tasks's callback. Just use the run() helper.

<?php

task('task_one', 'echo "Hello World!"');

task('task_two', function () {
  run('task_one');
});

Groups

Groups can be defined using the group() helper. Just use the task() helper inside the group's closure, and the task will automagically be assigned to that group.

<?php

group('my_group', function() {
  task('task_one', 'echo "Task One!"');
  task('task_two', 'echo "Task Two!"');
})

You can run an individual task by calling phake group:task, or run all tasks in the group by calling phake group.

phake my_group
# Output:
#   Task One!
#   Task Two!

phake my_group:task_one
# Output:
#   Task One!

Groups can be nested indefinitely, and running a group will run all tasks and groups within that group.

<?php

group('group', function() {
  task('first_task', 'echo "I\'m in the parent group"');

  group('subgroup', function() {
    task('second_task', 'echo "I\'m in the subgroup"');
  });
});
phake group
# Ouptut:
#   I'm in the parent group
#   I'm in the subgroup

Running multiple tasks

Each argument to phake is a task, and multiple tasks can be run by simply passing them all to phake. Based on the groups example above, this would give the same results as phake group:

phake group:first_task group:subgroup:second_task
# Ouptut:
#   I'm in the parent group
#   I'm in the subgroup

Options

By default phake looks for a Phakefile in the directory in which it is called. To use a custom directory, pass a path to the --dir (-d) option.

phake --dir=/path/to/root
phake -d/path/to/root

To use a different filename, or a Phakefile outside of the directory, use the --phakefile (-f) option.

phake --phakefile=/your/custom/file
phake -f/your/custom/file

To list all tasks or groups in a Phakefile, use the --tasks or --groups options.

phake --tasks
phake --groups

To hide any output produced by your tasks, use the --quiet (-q) option.

phake --quiet

molovo/phake 适用场景与选型建议

molovo/phake 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 91 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 02 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「phake」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 molovo/phake 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 molovo/phake 我们能提供哪些服务?
定制开发 / 二次开发

基于 molovo/phake 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-11