laravel 11. lorisleiva/laravel-actions。如何注册命令

问题描述 投票:0回答:1

如何在不使用

Console/Kernel.php
文件的情况下通过操作注册命令,因为
Laravel 11
中不存在该命令。 我执行了命令

composer requires laravel/tinker
php artisan vendor:publish --provider="Laravel\Tinker\TinkerServiceProvider"

config/tinker.php

 'commands' => [
      \App\Actions\SitemapGenerateAction::class,
 ],

这是行动

 use AsAction, AsCommand;

 public string $commandSignature = 'sitemap:generate';
 public string $commandDescription = 'Generate the sitemap';

 protected array $sitemapData;

 public function handle(): void
 {
 ...
 }

 public function asCommand(Command $command): void
 {
 ...
 }

 public function asController(): array
 {
 ...
 }
laravel command action laravel-11 tinker
1个回答
0
投票

如何在不使用 Console/Kernel.php 文件的情况下通过操作注册命令,因为 Laravel 11 中不存在该命令。我执行了该命令

在 laravel 11 中

kernal.php
不再存在。并且应该通过
bootstrap/app.php
文件进行配置。

任务调度,注册命令在laravel 11中是通过

routes/console.php
完成的。

有关更多详细信息,您可以查看此链接,您可以在其中定义命令。

https://laravel.com/docs/11.x/artisan#closure-commands

要清楚地了解 Laravel 11 上所做的更改,您可以查看此链接。

https://laravel-news.com/laravel-11-directory-struct

浏览完上面两个链接后,我想您将会清楚地了解如何注册和使用

routes/console.php

我在此链接中发布了类似的答案。你也可以检查一下。

Laravel Kernel.php 文件替代品

© www.soinside.com 2019 - 2024. All rights reserved.