Lumen5.3.2无法使用composer的make:model命令

今天用composer安装Lumen5.3.2并创建项目后,发现无法使用make:model的命令,提示CommandNotFoundException,于是输入php artisan list

命令显示所有可用的命令,发现make命令果然比laravel的少了很多,网上搜到解决办法,原问题链接为:http://stackoverflow.com/questions/34339517/lumen-laravel-eloquent-php-artisan-makemodel-not-defined,解决办法就是添加generators包,包在github的地址为:https://github.com/webNeat/lumen-generators。


1.执行以下命令,添加generators包到项目的composer.json文件中

composer require wn/lumen-generators


2.在app/Providers/AppServiceProvider.php文件中添加service provider,代码如下

public function register()
{
    if ($this->app->environment() == 'local') {
        $this->app->register('Wn\Generators\CommandsServiceProvider');
    }
}
3.在 bootstrap/app.php登记service provider,代码如下

$app->register(Wn\Generators\CommandsServiceProvider::class);

 4.再执行命令php artisan list,就能看到多了下面这些命令

wn:controller               Generates RESTful controller using the RESTActions trait
wn:controller:rest-actions  Generates REST actions trait to use into controllers
wn:migration                Generates a migration to create a table with schema
wn:model                    Generates a model class for a RESTfull resource
wn:pivot-table              Generates creation migration for a pivot table
wn:resource                 Generates a model, migration, controller and routes for RESTful resource
wn:resources                Generates multiple resources from a file
wn:route                    Generates RESTful routes.

命令具体的使用方法,见上面github的地址。

你可能感兴趣的:(Lumen5.3.2无法使用composer的make:model命令)