生成控制器和模型

2022-08-30 12:06:55

我是Laravel的新手,我玩过laravel 4(Beta版)。我想知道如何通过命令行使用生成控制器和模型。但我不知道该怎么做。php artisan


答案 1

观看此视频: http://youtu.be/AjQ5e9TOZVk?t=1m45s 您可以执行以下操作来查看所有命令, 生成 REST-ful 控制器的命令是 您可以通过以下方式查看用法:php artisan listcontroller:makephp artisan help make:controller


答案 2

拉拉维尔 5

其他答案对于Laravel 4来说很棒,但Laravel 5在这里!我们现在能够默认生成各种东西。运行以查看所有工匠命令。以下是所有命令:php artisan helpmake

make
  make:command         Create a new command class
  make:console         Create a new Artisan command
  make:controller      Create a new resource controller class
  make:event           Create a new event class
  make:middleware      Create a new middleware class
  make:migration       Create a new migration file
  make:model           Create a new Eloquent model class
  make:provider        Create a new service provider class
  make:request         Create a new form request class

注意:我们不再使用 item:make。相反,我们现在有make:item

跑步看看你能通过什么。例如,显示我们需要为它传递迁移名称,但我们也可以传递它或指定要分别创建或修改的表名称。运行以生成项目表。此外,生成模型还负责为该模型生成迁移。遵循命名约定,它将在迁移时将其复数化。php artisan help make:itemphp artisan help make:migration--create=""--table=""php artisan make:migration create_articles_table --create="articles"


推荐