atnic / lumen-generator
Generator for Lumen Framework.
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 1
Type:package
Requires
- php: >=7.1.3
- atnic/eloquent-filters: ^2.2
- laravel/lumen-framework: >=5.5 <5.8
- laravel/passport: >=4.0
- vlucas/phpdotenv: ~2.2
Requires (Dev)
- fzaninotto/faker: ~1.4
- mockery/mockery: ~1.0
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-12-09 09:00:09 UTC
README
Requirement
- php: >=7.1.3,
- phpunit/phpunit: ^7.0
Installation
Edit composer.json
{ "require": { "atnic/lumen-generator": "^0.1" }, "require-dev": { "phpunit/phpunit": "^7.0" } }
Then run composer update
. After that do this initial steps:
- Setup your
.env
file. - In
app/User.php
, addapi_token
in$hidden
property. - In
bootstrap/app.php
, uncomment and add some lines... $app->withFacades(); $app->withEloquent(); ... $app->routeMiddleware([ 'auth' => App\Http\Middleware\Authenticate::class, ]); ... $app->register(App\Providers\AppServiceProvider::class); $app->register(App\Providers\AuthServiceProvider::class); $app->register(App\Providers\EventServiceProvider::class); $app->register(Atnic\LumenGenerator\Providers\AppServiceProvider::class); $app->register(Atnic\LumenGenerator\Providers\ConsoleServiceProvider::class); $app->register(Laravel\Passport\PassportServiceProvider::class); ...
- Update
database/factories/ModelFactory.php
, addpassword
andapi_token
$factory->define(App\User::class, function (Faker\Generator $faker) { return [ 'name' => $faker->name, 'email' => $faker->email, 'password' => app('hash')->make('password'), 'api_token' => str_random() ]; });
- Update
.gitignore
/database/*.sqlite /storage/*.key
- In
phpunit.xml
, remove attributesyntaxCheck="false"
if exists (ex: Lumen 5.5), because its not compatible with new phpunit package - Then run
php artisan app:install
Make Module (CRUD)
This package is overriding some laravel artisan command.
This is example to make Foo module in this project
php artisan make:controller --model=Foo FooController
Then do this steps:
- Check new migration in
database/migrations/
, add column needed. - Check new factory in
database/factories/
, add atrribute needed. - Check new model in
app/
, add changes needed. - Check new filter in
app/Filters/
, do allTODO:
and remove the comment if done. - Check lang en
resources/lang/en
and copy from en to lang idresources/lang/id
, add language as needed. - Check new controller in
app/Http/Controllers/
, complete returned array in methodrelations()
visibles()
fields()
rules()
, do allTODO:
, and remove comment if done. - Check new policy in
app/Policies/
, do allTODO:
and remove the comment if done. - No need to append new Policy to
$policies
attribute inapp/Providers/AuthServiceProvider.php
. This package handle policy auto discovery, even for Laravel < 5.8. - Check new tests in
tests/Feature/
, do allTODO:
and remove the comment if done.
Other Useful command
# Creating Nested Controller php artisan make:controller --parent=Foo --model=Bar Foo/BarController # Create Single Action Controller php artisan make:controller DashboardController
All new/overrided command can be viewed in vendor/atnic/lumen-generator/app/Console/Commands
.