phptaskman/core
Composer 安装命令:
composer require phptaskman/core
包简介
A friendly PHP tasks launcher.
README 文档
README
PHP Taskman
Description
Taskman is a helper for running commands and tasks. It is shipped with a few simple default tasks.
It will help you in your every day life of setting up recurring tasks that you have to run in your projects.
Taskman is based on Robo and not tied to any framework or whatsoever.
Requirements
- PHP >= 5.6
Installation
composer require phptaskman/core
Configuration
Taskman can be customized in different ways:
- By setting arguments and options when running a command.
- By providing default values in configuration files. Taskman will read
the following files in the specified order. Options supplied in later files
will override earlier ones:
- The defaults provided by Taskman. This file is located inside the Taskman
repository in
config/default.yml. taskman.yml.dist- project specific defaults. This file should be placed in the root folder of the project that depends on Taskman. Use this file to declare default options which are expected to work with your application under regular circumstances. This file should be committed in the project.taskman.yml- project specific user overrides. This file is also located in the root folder of the project that depends on Taskman. This file can be used to override options with values that are specific to the user's local environment. It is considered good practice to add this file to.gitignoreto prevent it from being accidentally committed in the project repository.- User provided global overrides stored in environment variables. These can
be used to define environment specific configuration that applies to all
projects that uses Taskman, such as database credentials and the
Github access token. The following locations will be checked and the first
one that is found will be used:
$PHPTASKMAN_CONFIG$XDG_CONFIG_HOME/phptaskman/taskman.yml$HOME/.config/phptaskman/taskman.yml
- The defaults provided by Taskman. This file is located inside the Taskman
repository in
Optional packages
-
phptaskman/drupal Provides commands for your Drupal environment.
-
phptaskman/package Provide commands for generating packages out of your sources.
-
phptaskman/travis Provide commands to execute parts of your
.travis.ymlfile.
Usage
./vendor/bin/taskman
Then run a command:
./vendor/bin/taskman [NAME-OF-THE-COMMAND]
Documentation
The documentation is not up to date, this is a never ending work in progress.
Taskman will run commands. Commands contains one or multiple tasks.
Commands or tasks can be defined using YAML or through code.
An example of custom command with some tasks in a taskman.yml.dist file:
commands: foo:foo: - ls -la - { task: "mkdir", dir: "foo" } - ls -la - { task: "run", command: "foo:remove" } foo:remove: - rm -rf foo - ls -la
As you can see, there are 2 custom commands that are defined: foo:foo and foo:remove.
Those commands contains tasks, 4 tasks for foo:foo and 2 tasks for foo:remove.
A task can be either a string or a well structured array.
Expose custom tasks in YAML
Let's use the same example and add a custom task in the YAML file.
tasks: baz: - ls -la commands: foo:foo: - ls -la - { task: "mkdir", dir: "foo" } - ls -la - { task: "run", command: "foo:remove" } foo:remove: - rm -rf foo - { task: "baz" }
There are a few tasks that are supported by default in Taskman and provided by the phptaskman/core-tasks package.
Expose custom commands in YAML
Taskman allows you to expose new commands using a YAML file (taskman.yml.dist or taskman.yml). Commands can reference each other, allowing for complex scenarios to be implemented with relative ease.
- Create a file
taskman.ymlortaskman.yml.distin your project, and start adding commands:
commands:
hello-world:
- echo "Hello"
- echo "world !"
- { task: "mkdir", dir: "foo" }
datetime:
- date -u
Taskman will automatically look into your package dependencies for such files automatically.
This means that you can create custom packagist packages containing your taskman.yml file with your custom commands.
Advanced custom commands
You can define also command options along with a custom command.
commands: setup:behat: description: Write a short description of your task here. help: Write a short help text here. # When you need to define command options, the list of tasks should be # placed under the 'tasks' key... tasks: - { task: "process", source: "behat.yml.dist", destination: "behat.yml" } # Add preconditions that are going to be evaluated before running the command. # If one of these preconditions does not return 0, the command is not run. preconditions: - test -f .env # ...and option definitions are under the 'options' key. options: # The option name, without the leading double dash ('--'). webdriver-url: # Optional. If this key is present, the input option value is assigned # to this configuration entry. This a key feature because in this way # you're able to override configuration values, making it very helpful # in CI flows. config: behat.webdriver_url # Optional. You can provide a list of shortcuts to the command, without # adding the dash ('-') prefix. shortcut: - wdu - wurl # The mode of this option. See the Symfony `InputOption::VALUE_*` # constants. Several options can be combined. # @see \Symfony\Component\Console\Input\InputOption::VALUE_NONE # @see \Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED # @see \Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL # @see \Symfony\Component\Console\Input\InputOption::VALUE_IS_ARRAY mode: 4 # Optional. A description for this option. This is displayed when # asking for help. E.g. `./vendor/bin/run setup:behat --help`. description: 'The webdriver URL.' # Optional. A default value when an optional option is not present in # the input. default: null
Define global command options
You can define global options that can be applied to any command.
globals: options: env: description: Environment default: dev commands: test:command: tasks: - echo "Running on environment ${options.env}"
Now you can run the command and change the value of the command option dynamically:
./bin/console test:command --env=prod
Contributing
See Contributing.
phptaskman/core 适用场景与选型建议
phptaskman/core 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.93k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2019 年 04 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 phptaskman/core 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phptaskman/core 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 18
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-16