DEV Community

JC Soriano
JC Soriano

Posted on

Speed up your Laravel development using CRUD Templates

Hi Laravel developers!

I've recently created a new package designed to radically speed up your Laravel application development by generating routes, controllers, models, migrations, factories, requests, resources, and tests - all using a single command.

Quick Example

Let's generate a complete CRUD API for the Post model:

php artisan crud:generate Content/Post \
  --template=api \
  --fields="title:string,content:text,published_at:datetime,category:belongsTo,comments:hasMany,status:enum:PublishStatus" \
  --options="scope:user"
Enter fullscreen mode Exit fullscreen mode

The above command generates the following fully functional files:

  • app/Http/Controllers/Api/Content/PostController.php
  • app/Models/Content/Post.php
  • app/Policies/PostPolicy.php
  • app/Http/Requests/Content/StorePostRequest.php
  • app/Http/Requests/Content/UpdatePostRequest.php
  • app/Http/Resources/Content/PostResource.php
  • database/migrations/{timestamp}_create_posts_table.php
  • database/migrations/{timestamp}_create_{pivot}_tables.php (if belongsToMany or morphToMany relationships are present)
  • database/factories/Content/PostFactory.php
  • tests/Feature/Api/Content/PostControllerTest.php
  • API routes automatically added to routes/api.php (will run install:api if the file doesn't exist yet)
  • Laravel Pint run on all generated files

Check it out

๐Ÿ”— Package: jcsoriano/laravel-crud-templates
๐Ÿ“š Documentation: laravelcrudtemplates.com
๐Ÿ™ GitHub: github.com/jcsoriano/laravel-crud-templates

3-minute demo

Top comments (0)