bramf / crud-generator
Crud generator for lumen with Open Api annotations
Installs: 1 217
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- awobaz/compoships: ^2.2.3
- doctrine/dbal: ^3.6
- flipbox/lumen-generator: ^9.2.0
- zircote/swagger-php: ^4.7
- dev-master
- v3.4
- v3.3
- v3.2.3.1
- v3.2.3
- v3.2.2.3
- v3.2.2.2
- v3.2.2.1
- v3.2.2
- v3.2.1
- v3.2.0.1
- v3.2
- v3.1.9
- v3.1.8
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1
- v3.0.9
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0
- v2.9.1.5
- v2.9.1.4
- v2.9.1.3
- v2.9.1.2
- v2.9.1.1
- v2.9.1
- v2.9.0
- v2.8.9.8
- v2.8.9.7
- v2.8.9.6
- v2.8.9.5
- v2.8.9.4
- v2.8.9.3
- v2.8.9.2
- v2.8.9.1
- v2.8.9
- v2.8.8.3
- v2.8.8.2
- v2.8.8.1
- v2.8.8
- v2.8.7
- v2.8.6.1
- v2.8.6
- v2.8.5
- v2.8.4
- v2.8.3
- v2.8.2
- v2.8.1.3
- v2.8.1.2
- v2.8.1.1
- v2.8.1
- v2.8
- v2.7.2
- v2.7.1
- v2.7
- v2.6.6
- v2.6.5
- v2.6.4
- v2.6.3
- v2.6.2.2
- v2.6.2.1
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5
- v2.4.1
- v2.4
- v2.3
- v2.2
- v2.1.2
- v2.1.1
- v2.1
- v2.0.1
- v2.0
- v1.9
- v1.8
- v1.7
- v1.6
- v1.5
- v1.4
- 1.3
- 1.2
- v1.0
This package is auto-updated.
Last update: 2025-03-01 00:39:47 UTC
README
Lumen package for generate crud controller,model and routes
Installation
Run commands below:
composer require bramf/crud-generator
Environment Variables
After installing package change database connection settings and put SWAGGER_VERSION,PACKAGE_AUTHOR variable to your .env file:
DB_CONNECTION=YOUR_DB_TYPE[for example mysql,pgsql]
DB_HOST=DATABASE_HOST
DB_PORT=DATABASE_PORT
DB_DATABASE=DATABASE_NAME
DB_USERNAME=DATABASE_USERNAME
DB_PASSWORD=DATABASE_PASSWORD
SWAGGER_VERSION=3.0
PACKAGE_AUTHOR=AUTHOR_NAME
Configuration
Add CrudGeneratorProvider to providers section in bootstrap/app.php:
/* |-------------------------------------------------------------------------- | Register Service Providers |-------------------------------------------------------------------------- | | Here we will register all of the application's service providers which | are used to bind services into the container. Service providers are | totally optional, so you are not required to uncomment this line. | */ // $app->register(App\Providers\AppServiceProvider::class); // $app->register(App\Providers\AuthServiceProvider::class); // $app->register(App\Providers\EventServiceProvider::class); $app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class); $app->register(Bramf\CrudGenerator\CrudGeneratorServiceProvider::class);
Uncomment the $app->withEloquent() and $app->withFacades() call in your bootstrap/app.php:
/* |-------------------------------------------------------------------------- | Create The Application |-------------------------------------------------------------------------- | | Here we will load the environment and create the application instance | that serves as the central piece of this framework. We'll use this | application as an "IoC" container and router for this framework. | */ $app = new Laravel\Lumen\Application( dirname(__DIR__) ); $app->withFacades(); $app->withEloquent();
Run package migrations:
php artisan migrate
Usage
Before use command you need to create and run migration, that creates table for CRUD operations, for example:
php artisan make:migration create_tests_table
php artisan migrate
Commands
php artisan make:crud
Command will ask you required parameters to make CRUD:
Controller name:
>
CRUD url:
>
Model name:
>
Table name:
>
- Controller name: name of controller for CRUD operations.
- CRUD url: route for CRUD operations. For example, value api/test will generate routes like this:
/** * Controller routes */ $router->group(["prefix"=>"api/test"],function() use($router){ // CRUD $router->post("/","TestController@create"); $router->get("/","TestController@all"); $router->get("/{id}","TestController@get"); $router->put("/{id}","TestController@update"); $router->delete("/{id}","TestController@delete"); });
- Model name: name of model for CRUD operations.
- Table name: name of table for CRUD operations.
You can check new routes with command
php artisan route:list
This command also calls
php artisan make:swagger
command, that generate json file with open api annotations. File location:
./public/swagger.json
Additional commands:
php artisan crud:route
Delete crud route group by id, or all route groups, if you set id = 0
php artisan make:crud:table
Generate CRUD for all your tables. You can set names of tables, that will be excluded from generation. Default names of tables, that will be excluded: 'users','crud_route_groups','migrations'.