corex / lconsole
该包已被弃用,不再维护。没有建议的替代包。
Laravel 控制台 (artisan, 命令, 可见性)
1.0.1
2017-06-22 07:50 UTC
Requires
- php: >=5.6.4
- laravel/framework: ^5.4
Requires (Dev)
- laravel/laravel: 5.4.*
- orchestra/testbench: ~3.0
- phpunit/phpunit: 5.7.*
This package is auto-updated.
Last update: 2020-04-15 05:14:46 UTC
README
Laravel 控制台 (artisan, 命令, 可见性)。
此包的版本遵循 http://semver.org/。升级到主要版本可能会破坏向后兼容性。
对于较大的 Laravel 安装,artisan 命令列表可能相当长。此包允许您拥有自己的 artisan,并包含您选择的命令。
警告:现有的 Laravel 命令(如 route:list)仅被隐藏。如果您添加与现有命令具有相同签名的命令,它将覆盖现有命令。如果发生这种情况,您将无法使用 $this->call() 来调用被覆盖的 Laravel 命令。
安装
运行 "composer require corex/lconsole"
。
现在您有两个选项。
选项 1
注册提供者并使命令在 Laravel artisan 中可用。
将以下代码添加到 AppServiceProviders@register 方法中。
if ($this->app->environment() == 'local') { $this->app->register(\CoRex\Laravel\Console\ConsoleServiceProvider::class); }
选项 2
将包中的 "artisan" 文件复制到 Laravel 安装根目录,并重命名它。
设置 artisan
最后修改创建的 artisan 文件以满足您的需求。
新 artisan 的示例。
require_once(__DIR__ . '/vendor/autoload.php'); $artisan = new \CoRex\Laravel\Console\Artisan(__DIR__); // Set name on artisan. //$artisan->setName('name'); // Set version on artisan. //$artisan->setVersion('x.y.z'); // Add single command. //$artisan->addCommand(MyCommand::class); // Add multiple commands on specified path. //$artisan->addCommandsOnPath(path-to-commands, true, ''); $artisan->execute();
将所有命令以 "Command"(例如 "MyCommand")结尾是一种好习惯。这样,您就可以仅将您的命令添加到 "$artisan->addCommandsOnPath()",而不会添加其他类(例如助手类)。
修改后 artisan 的示例。
require_once(__DIR__ . '/vendor/autoload.php'); $artisan = new \CoRex\Laravel\Console\Artisan(__DIR__); // Set name on artisan. $artisan->setName('Test'); // Set version on artisan. $artisan->setVersion('1.0.0'); // Add single command. //$artisan->addCommand(MyCommand::class); // Add multiple commands on specified path. $artisan->addCommandsOnPath(__DIR__ . '/app/Console/Commands, true, ''); $artisan->execute();