exs/terminal-bundle
Composer 安装命令:
composer require exs/terminal-bundle
包简介
Terminal command logging bundle for Symfony2
README 文档
README
Terminal bundle to log all command output regardless of output buffer (echo / print_r / var_dump / ->ln()), lock commands to prevent them from running concurrently, provide command stats (pid, runtime, errors) and log any exceptions / errors in the database. Very useful for controlling commands via web interface when commands are being run via cronjob. Handles legacy code that was ported tyo your symfony2 app quick and dirty.
Bundle is installed as a service listening for all exceptions and logging them in the database. Locks use the command alias as the slug for ease of reference. When used in conjunction with a crontab enabled monitor we can then alert the dev team when there are errors, current lock hits, and review the logs via web interface instead of having to login to the particular host that had the problem.
Options
--output (-o) Output type (console, db (default: "console")
--lock=true (-l) Whether or not to lock the console command
Installing the TerminalBundle in a new Symfony2 project
So the TerminalBundle is ready for installation, great news but how do we install it. The installation process is actually very simple. Set up a new Symfony2 project with Composer.
Once the new project is set up, open the composer.json file and add the exs/terminal-bundle as a dependency:
//composer.json //... "require": { //other bundles "exs/terminal-bundle": "dev-master"
Save the file and have composer update the project via the command line:
php composer.phar update
Composer will now update all dependencies and you should see our bundle in the list:
- Installing exs/terminal-bundle (dev-master 463eb20)
Cloning 463eb2081e7205e7556f6f65224c6ba9631e070a
Update the app/AppKernel.php and app/config/routing.yml to include our bundle, clear the cache and update the schema:
//app/AppKernel.php //... public function registerBundles() { $bundles = array( //Other bundles new EXS\TerminalBundle\EXSTerminalBundle() );
#app/config/config.yml
#...
exs_terminal:
email:
from: from@test.tld
to: to@test.tld
subject: Subject
You have to manually update the db with doctrine:schema:update console command.
Migrations won't work because they need the table that they're going to create...
php app/console cache:clear php app/console doctrine:schema:update --force
Lastly, copy the including bash file: "runner" from the vendor/exs/terminal-bundle/EXS/TerminalBundle/runner to app/runner That adds the hooks into the original console script without altering the original.
cp vendor/exs/terminal-bundle/EXS/TerminalBundle/runner app/runner
Make sure you're mailer is properly configurated in config.yml and in parameters.yml:
#app/config/config.yml
#...
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
and now you're done.
If you want to test them try opening up the same command in two terminals simultaneously. They currently run for 3 seconds each:
php app/runner terminal:test:lock_sleep --lock=true -o=db php app/runner terminal:test:lock_sleep --lock=true -o=db
Once you're run the above command you will be able to verify everything worked by checking the database. The locks and logs will be logged in your database in the following tables:
-
terminallogs
-
commandlocks
Additionally if your command exited with a non 0 status it likely logged an exception in the exception5xx table.
Contributing
Anyone and everyone is welcome to contribute.
If you have any questions or suggestions please let us know.
exs/terminal-bundle 适用场景与选型建议
exs/terminal-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.86k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 05 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「logging」 「exception」 「error」 「bundle」 「command」 「crontab」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 exs/terminal-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 exs/terminal-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 exs/terminal-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Zend Framework module that sets up Monolog for logging in applications.
Asynchronous Sentry for Symfony - Fire and forget
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
High-performance, zero-dependency PSR-3 logger for MonkeysLegion with structured logging, handlers, processors, and PHP 8.4 features.
PHP Error Handler module that captures and displays all throwable errors in a given format, making debugging easier and more efficient
Error and Exception override and observers.
统计信息
- 总下载量: 3.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 35
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-15