tobento/app-console
Composer 安装命令:
composer require tobento/app-console
包简介
App console support.
README 文档
README
Console support for the app using the Console Service.
Table of Contents
Getting Started
Add the latest version of the app console project running this command.
composer require tobento/app-console
Requirements
- PHP 8.4 or greater
Documentation
App
Check out the App Skeleton if you are using the skeleton.
You may also check out the App to learn more about the app in general.
Console Boot
The console boot does the following:
- creates app file in the root directory if not exist
- implements console interfaces
use Tobento\App\AppFactory; use Tobento\Service\Console\ConsoleInterface; use Tobento\Service\Console\ConsoleFactoryInterface; // Create the app $app = new AppFactory()->createApp(); // Add directories: $app->dirs() ->dir(realpath(__DIR__.'/../'), 'root') ->dir(realpath(__DIR__.'/../app/'), 'app') ->dir($app->dir('app').'config', 'config', group: 'config') ->dir($app->dir('root').'public', 'public') ->dir($app->dir('root').'vendor', 'vendor'); // Adding boots $app->boot(\Tobento\App\Console\Boot\Console::class); $app->booting(); // Implemented interfaces: $consoleFactory = $app->get(ConsoleFactoryInterface::class); $console = $app->get(ConsoleInterface::class); // Run the app $app->run();
If you are not using the App Skeleton you may adjust the ap file in the root directory with the path to your app:
// Get and run the application. // (require __DIR__.'/app/app.php')->run(); (require __DIR__.'/path/to/app.php')->run();
Creating Commands
Check out the Console Service - Creating Commands section to learn more about creating commands.
Adding Commands
You can add commands in severval ways:
Using the app
You may use the app on method to register commands only if the console is requested.
use Tobento\App\AppFactory; use Tobento\Service\Console\ConsoleInterface; // Create the app $app = new AppFactory()->createApp(); // Add directories: $app->dirs() ->dir(realpath(__DIR__.'/../'), 'root') ->dir(realpath(__DIR__.'/../app/'), 'app') ->dir($app->dir('app').'config', 'config', group: 'config') ->dir($app->dir('root').'public', 'public') ->dir($app->dir('root').'vendor', 'vendor'); // Adding boots: $app->boot(\Tobento\App\Console\Boot\Console::class); // Adding commands: $app->on(ConsoleInterface::class, function(ConsoleInterface $console) { $console->addCommand($command); }); // Run the app $app->run();
Using the console boot
use Tobento\App\Boot; use Tobento\App\Console\Boot\Console; class AnyServiceBoot extends Boot { public const BOOT = [ // you may ensure the console boot. Console::class, ]; public function boot(Console $console) { // you may add commands only if running in console: if ($console->runningInConsole()) { $console->addCommand($command); } } }
Invoke Commands
To invoke application command just run:
php ap command:name
To get a list of available commands:
php ap list
Credits
tobento/app-console 适用场景与选型建议
tobento/app-console 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 158 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「console」 「app」 「tobento」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tobento/app-console 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tobento/app-console 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tobento/app-console 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This class provides you with an easy-to-use interface to progress bars.
A Laravel package to retrieve data from Google Search Console
Additional artisan commands for Laravel
Make your bundle an application
A table generator class for the PHP CLI.
统计信息
- 总下载量: 158
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 13
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-01