groovili / lumen-make
Lumen make adds more make commands to lumen for jobs, controllers, middleware, etc.
Installs: 243
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 5
Open Issues: 0
Type:lumen
Requires
- laravel/lumen-framework: ~5.4
This package is not auto-updated.
Last update: 2024-11-10 05:56:38 UTC
README
A package built for Lumen that ports most of the make commands from Laravel and adds Form Request Validation functionality.
At the moment package compatible only with Lumen >= 5.6.
Installation
Just run the following command
> composer require groovili/lumen-make
or this to enable package only for development needs
> composer require groovili/lumen-make --dev
Uncomment or add this line in bootstrap/app.php
$app->register(App\Providers\EventServiceProvider::class);
And add this to bootstrap/app.php
to enable generators
// To enable generator permanently $app->register(Groovili\LumenMake\LumenMakeServiceProvider::class); // To enable generator in development mode if (env('APP_ENV') !== 'production' || env('APP_ENV') === 'local') { $app->register(Groovili\LumenMake\LumenMakeServiceProvider::class); }
Form Request Validation
Add line to bootstrap/app.php
to enable form requests
$app->register(Groovili\LumenMake\Providers\FormRequestServiceProvider::class);
Then run
> php artisan make:request {name}
Below is example of generated request with validation rules:
<?php declare(strict_types=1); namespace App\Http\Requests; use Groovili\LumenMake\Requests\FormRequest; /** * Class FooBarRequest * @package App\Http\Requests */ class FooBarRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize(): bool { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'foo' => 'bail|required|max:255|min:3', 'bar' => 'bail|required|max:255|min:3', ]; } }
Migrate to Laravel
In generated requests Groovili\LumenMake\Requests
is used.
If you want migrate to Laravel - change use line in all generated requests:
use Groovili\LumenMake\Requests\FormRequest; // change to use Illuminate\Foundation\Http\FormRequest;
Available commands
make:job {name}
- Job class inJobs/
make:console {name}
- Console command inConsole/Commands/
make:controller {name}
- Restful controller inHttp/Controllers/
make:model {name}
- Model in/
make:middleware {name}
- Middleware class inHttp/Middleware/
make:exception {name}
- Exception class inExceptions/
make:event {name}
- Event class inEvents/
make:request {name}
- Request class inHttp/Requests/