Laravel CRUD Generator
Table of content
The Conventions section explain very important concepts.
Please read it carrefully before using this package.
This package allows to generate CRUDs in a breath for your Laravel 5.5+ applications.
Please have a look to this short video on Vimeo to see it in action.
Using the SignedInput syntax, it offers a concise and handy way to define the model fields.
It is designed to create easily custom CRUDs, aka themes.
Two simple themes are provided :
- crud:classic generates a fully fonctionnal "classic" CRUD.
It creates for you : migration, model, factory, seeder, request, resource, controller, blade views and routes.
- crud:api generates a fully fonctionnal REST API CRUD.
It creates for you : migration, model, factory, seeder, request, resource, controller and routes.
Simply import the package as a dev dependency into your Laravel application:
composer require --dev bgaze/laravel-crud
You can publish the package configuration to
php artisan vendor:publish --provider=Bgaze\Crud\ServiceProvider
And classic themes views to
php artisan vendor:publish --tag=crud-classic-views
Why this package?
Laravel is my favorite PHP framework.
But using it daily, at work and for my private projects, I realized that each time I create a model, I was wasting a lot of time doing repetitive tasks instead of really working on the application itself:
- Generate classes: model, migration, controller, request, factory, seeder, ...
- Define the table fields into migration.
- Create the rules into the request class.
- Create the model faker into factory.
- Define CRUD actions into controller.
- Register controller routes.
- Create CRUD views and model forms.
I believe that this process can be automated a lot to produce a generic functionnal CRUD that we just need to customize, keeping the focus on the application logic.
The key for that is to define the Model table fields from whom, sticking to the framework conventions, a lot of things can be deducted.
For instance request rules or form fields: a non-nullable field is required, an enum field is often a select.
But even if CRUD generation logic will be almost the same, the files to generate can vary a lot depending on the tools used.
For instance, using classic HTML or Vue.js, a CRUD files will be very different.
So this package goals are to provide:
- A handy way to define required informations for a CRUD generation.
- An extensible base to create easily custom CRUD generators (named themes).
- Two simple themes to use as base for custom CRUDs:
- A REST API CRUD.
- A standart CRUD using Blade templates.
CRUD generator need to manipulate Model name in order to generate required ressources.
As a convention, we designate by:
- FullName: the model's name including namespace without the
- Plural: the FullName with last segment pluralized.
- Plurals: the FullName with each segments pluralized.
Models: \App\MyGrandParent \App\MyGrandParent\MyParent \App\MyGrandParent\MyParent\MyChild FullName: MyGrandParent MyGrandParent\MyParent MyGrandParent\MyParent\MyChild Plural: MyGrandParents MyGrandParent\MyParents MyGrandParent\MyParent\MyChildren Plurals: MyGrandParents MyGrandParents\MyParents MyGrandParents\MyParents\MyChildren