woodynadobhar / dingo2generators
Laravel REST API scaffolding.
Requires
- php: >=5.6.4
- abhijitghogre/laravel-db-clear-command: ^1.0
- barryvdh/laravel-ide-helper: ^2.3@dev
- darkaonline/l5-swagger: ^5.5
- dingo/api: 2.0.0-alpha1
- felixkiss/uniquewith-validator: ^3.1
- laravel/framework: ~5.5.0
- laravel/tinker: ~1.0
- tymon/jwt-auth: 0.5.*
- xethron/migrations-generator: ^2.0
Requires (Dev)
- mockery/mockery: 0.9.*
- phpunit/phpunit: ~5.7
This package is auto-updated.
Last update: 2024-12-17 12:17:33 UTC
README
Laravel REST API Generator
Code scaffolding for REST API project by database schema. This package is available also on packagist. And installation via packagist is preferred way.
Examples
There are two open source REST API projects on GitHub, developed using this generator:
Installation
Package installation
- add
"woodynadobhar/dingo2generators": "dev-master"
to your composer.json (node"require"
) - set
"minimum-stability": "dev"
in your composer.json - run
composer update
Configuration
Open your config/app.php
and add this line in providers
section
WoodyNaDobhar\Dingo2Generators\GeneratorsServiceProviders::class, Dingo\Api\Provider\LaravelServiceProvider::class, Way\Generators\GeneratorsServiceProvider::class, Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class, Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class, L5Swagger\L5SwaggerServiceProvider::class, Abhijitghogre\LaravelDbClearCommand\LaravelDbClearCommandServiceProvider::class, Felixkiss\UniqueWithValidator\ServiceProvider::class,
Publishing configuration files
Execute command
php artisan vendor:publish
Open your config/jwt.php
and change line with a user's model namespace.
'user' => 'App\REST\User',
Configurating .env file
- set proper connection to the database
- add configuration for dingo/api package. See detailed docs here
- required configuration string is
API_DOMAIN=yourdomain.dev
Register middleware
Add middleware to App/Http/Kernel.php to the $routeMiddleware array.
'check.role.access' => \WoodyNaDobhar\Dingo2Generators\Middleware\CheckAccess::class,
Swagger configuration
Add '/routes' path in 'config/l5-swagger.php', annotation path.
'annotations' => [base_path('app'), base_path('routes')],
Database schema
Make sure, that you have created database schema. For generating relations you should have FOREIGN KEY Constraints.
Generating code for REST API project
- Run artisan command for code scaffolding.
php artisan make:rest-api-project
- Generate swagger documentation.
php artisan l5-swagger:generate
- Execute command
composer dump-autoload
- 🐘 💥 👍 👍