Reputation: 11324
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 ?
php artisan --version
Displays :
Laravel Framework version Lumen (5.1.6) (Laravel Components 5.1.*)
Upvotes: 47
Views: 61987
Reputation: 46
there are some packages that can help you to have all of artisan command that you has on Laravel . install below package to have more artisan command. https://github.com/flipboxstudio/lumen-generator
Upvotes: 0
Reputation: 1
$app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class); add this line into "bootstrap\app.php" and save this file then make the command.It will work.
Upvotes: 0
Reputation: 14844
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
Upvotes: 37
Reputation: 421
just create your model file manually in the app directory
example
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model {
protected $table = ‘articles’;
protected $fillable = [
‘title’,
‘description’,
‘body’
];
}
Upvotes: 2
Reputation: 1330
Go to the project directory and add the generators package to your composer.json
using the following command:
composer require wn/lumen-generators
Add following code segment to app/Providers/AppServiceProvider.php
:
public function register()
{
if ($this->app->environment() == 'local') {
$this->app->register('Wn\Generators\CommandsServiceProvider');
}
}
Make sure that you have un-commented the following line in bootstrap/app.php
to allow service providers on your project:
$app->register(App\Providers\AppServiceProvider::class);
Run php artisan list
on the project directory (document root). Now you will see new items there.
Upvotes: 14
Reputation: 35180
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!
Upvotes: 47