fdevs/cron-bridge
Composer 安装命令:
composer require fdevs/cron-bridge
包简介
Symfony 2 bridge which allows you to use config to configure cron to run your console commands.
README 文档
README
Easily configure cron through PHP.
Setup and Configuration
FDevsCron uses Composer, please checkout the composer website for more information.
The simple following command will install cron-bridge into your project. It also add a new
entry in your composer.json and update the composer.lock as well.
$ composer require fdevs/cron-bridge
FDevsCron follows the PSR-4 convention names for its classes, which means you can easily integrate
cronclasses loading in your own autoloader.
Usage with Symfony framework
###Enable the bundle in the kernel
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new FDevs\Bridge\Cron\FDevsCronBundle(), // ... ); }
###add command
#app/config/config.yml f_devs_cron: commands: swiftmailer: command: 'swiftmailer:spool:sends' bin: executor: '/usr/bin/php' command: 'your_best_command'
default configuration
# Default configuration for extension with alias: "f_devs_cron" f_devs_cron: exporter: key: f_devs_cron # Example: generated mailto: ~ # Example: cron@example.com path: '/usr/local/bin:/usr/bin:/bin' # Example: /usr/local/bin:/usr/bin:/bin executor: php # Example: php console: bin/console # Example: bin/console(symfony 3.0) shell: ~ # Example: /bin/sh commands: # Prototype name: command: ~ # Required, Example: swiftmailer:spool:send minute: '*' # Example: */5 - Every 5 minutes hour: '*' # Example: 8 - 5 minutes past 8am every day day_of_week: '*' # Example: 0 - 5 minutes past 8am every Sunday day: '*' # Example: 1 - 5 minutes past 8am on first of each month month: '*' # Example: 1 - 5 minutes past 8am on first of of January log_file: ~ # Example: %kernel.logs_dir%/%kernel.environment%_cron.log error_file: ~ # Example: %kernel.logs_dir%/%kernel.environment%_error.log params: '' # Example: --color=red # add if use custom executor executor: ~ # Example: /usr/bin/php
###use console command
$ bin/console fdevs:cron:dump $ bin/console fdevs:cron:replace $ bin/console fdevs:cron:delete
Usage with The Console Component
#!/usr/bin/env php <?php // application.php require __DIR__.'/vendor/autoload.php'; use FDevs\Bridge\Cron\Command\DeleteCommand; use FDevs\Bridge\Cron\Command\DumpCommand; use FDevs\Bridge\Cron\Command\ReplaceCommand; use FDevs\Cron\Cron; use FDevs\Cron\CrontabUpdater; use Symfony\Component\Console\Application; $cron = new Cron() // $cron configuration... $crontabUpdater = new CrontabUpdater('uniquie_key'); $application = new Application(); $application->add(new ReplaceCommand('cron:replace', $cron, $crontabUpdater)); $application->add(new DumpCommand('cron:dump', $cron)); $application->add(new DeleteCommand('cron:delete', $crontabUpdater)); $application->run();
use in console
$ php application.php cron:replace $ php application.php cron:dump $ php application.php cron:delete
Usage with The DependencyInjection Component
<?php use Symfony\Component\DependencyInjection\ContainerBuilder; use FDevs\Bridge\Cron\DependencyInjection\FDevsCronExtension; use FDevs\Bridge\Cron\DependencyInjection\Compiler\CronJobPass; $container = new ContainerBuilder(); // $container configuration... $container->registerExtension(FDevsCronExtension()); $container->addCompilerPass(new CronJobPass()); $updater = $container->get('f_devs_cron.crontab_updater'); $cron = $container->get('f_devs_cron.cron'); $updater->replace($cron); echo strval($cron);
Created by 4devs - Check out our blog for more insight into this and other open-source projects we release.
fdevs/cron-bridge 适用场景与选型建议
fdevs/cron-bridge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 217 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 05 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cron」 「crontab」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fdevs/cron-bridge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fdevs/cron-bridge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fdevs/cron-bridge 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony bundle to monitor and execute commands
Provides a possibility to auto-setup crontabs required for project based on configuration file.
symfony bundle for jobbyphp/jobby
Scheduling extension for Yii2 framework
Monitoring for scheduled jobs
Yii2 scheduler module
统计信息
- 总下载量: 217
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-05-14