【问题标题】:Laravel create customs packages with commandsLaravel 使用命令创建自定义包
【发布时间】:2018-06-11 11:21:58
【问题描述】:

我希望在 Laravel 中创建一个通用的预约系统,我想在我的其他项目中使用它。 有没有办法通过创建自定义命令来实现?例如,php artisan make:auth 创建完整的登录、注册、忘记和重置密码功能。 我也想做同样的事情,比如php artisan appoitment : make,它应该在 Laravel 安装中创建模型、控制器和数据库迁移

【问题讨论】:

  • 你有没有通过尝试like this来尝试任何东西并得到任何错误?

标签: php laravel-5 command laravel-artisan


【解决方案1】:
  1. php artisan make:command {命令名}。您可以在 app/console/commands 目录中看到 {command name} 文件。
  2. 将 $signature 更改为 appoitment:make。
  3. 将您的命令类添加到 app/console/Kernel.php 命令列表。

例如:

php artisan make:command AppoitmentCommand

In Kernel.php : $commands = [
    AppoitmentCommand::class
];

php artisan //you can see all commands

【讨论】:

  • 在您的自定义命令中,您可以运行其他命令,例如 php artisan make:model 等。更多详细信息请阅读Laravel document
猜你喜欢
  • 2020-09-20
  • 2011-10-22
  • 2015-12-30
  • 1970-01-01
  • 2013-08-30
  • 2015-04-14
  • 2019-03-03
  • 1970-01-01
  • 2016-07-13
相关资源
最近更新 更多