Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lumen (Laravel) Eloquent php artisan make:model not defined

I use Lumen 1.0 for an API project.

I have already enable Eloquent by uncomment the following line in bootstrap/app.php file :

$app->withEloquent(); 

But when I want to create my first model with migration it fails :

php artisan make:model Book --migration 

Error message :

  [InvalidArgumentException]   Command "make:model" is not defined.   Did you mean one of these?       make:seeder       make:migration 

Laravel doc about Eloquent (http://laravel.com/docs/5.1/eloquent#defining-models).

Lumen doc (http://lumen.laravel.com/docs/installation) doesn't include Eloquent doc because, it's not enable by default.

Do you have any ideas to avoid this error ?

Add details

php artisan --version 

Displays :

Laravel Framework version Lumen (5.1.6) (Laravel Components 5.1.*) 
like image 501
Samuel Dauzon Avatar asked Dec 17 '15 16:12

Samuel Dauzon


People also ask

Does Lumen use eloquent?

Of course, you may easily use the full Eloquent ORM with Lumen. To learn how to use Eloquent, check out the full Laravel documentation.

Which artisan command makes another artisan command?

To create a new artisan command, we can use the make:command artisan command. This command will make a new command class within the app/Console/Commands catalog. In case the directory does not exist in our laravel project, it'll be automatically made the primary time we run the artisan make:command command.

What is php artisan optimize?

php artisan optimize creates a compiled file of commonly used classes in other to reduce the amount of files that must be included on each request. After running the command, all commonly used classes are compiled and then saved to this file directory: bootstrap/cache/compiled.


2 Answers

You're seeing this error because Lumen doesn't come with make:model.

To see a list of all the artisan commands you have at your disposal just run php artisan.

That being said I did just find this package which I've added to a lumen installation and it seems to work fine https://github.com/webNeat/lumen-generators#installation

Hope this helps!

like image 130
Rwd Avatar answered Oct 02 '22 11:10

Rwd


If you check all the available commands using php artisan list you will see that you don't have all the default ones offered by laravel. But you can get the most importants using the lumen-generator package (not to be confused with lumen-generators). It has the advantage of offering more commands than the other one mentioned.

To use it just install it using composer:

composer require flipbox/lumen-generator 

Then enable it in your bootstrap/app.php file:

$app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class); 

You will now be able to use all these new commands using artisan:

key:generate      Set the application key  make:command      Create a new Artisan command make:controller   Create a new controller class make:event        Create a new event class make:job          Create a new job class make:listener     Create a new event listener class make:mail         Create a new email class make:middleware   Create a new middleware class make:migration    Create a new migration file make:model        Create a new Eloquent model class make:policy       Create a new policy class make:provider     Create a new service provider class make:seeder       Create a new seeder class make:test         Create a new test class 

Just have a look at the official documentation: https://github.com/flipboxstudio/lumen-generator

like image 32
johannchopin Avatar answered Oct 02 '22 11:10

johannchopin