worksofallen/laravel-api-scaffold

A simple way to send batch emails

v1.0.2 2025-06-05 05:10 UTC

This package is auto-updated.

Last update: 2025-06-05 05:12:20 UTC


README

Status License PHP Latest Version on Packagist Downloads

A Laravel Artisan command to quickly scaffold a complete RESTful API resource, including:

  • Eloquent Model with SoftDeletes & fillable setup
  • Migration file with a name column and soft deletes support
  • API Controller with basic CRUD operations & pagination, filtering, sorting
  • Form Request classes for validation with proper JSON error responses

Installation

Require the package via Composer:

composer require worksofallen/laravel-api-scaffold:v1.0.0 --dev

Publish the command if necessary (depends on how you package it).

Usage

Run the custom Artisan command to generate a full API scaffold for a resource:

php artisan make:api {name}

Replace {name} with the singular model name, e.g., Product, Category, etc.

What gets created?

  • app/Models/{Name}.php — Model with fillable name attribute and soft deletes.
  • database/migrations/xxxx_xx_xx_xxxxxx_create_{snake_plural}_table.php — Migration with name and soft deletes columns.
  • app/Http/Requests/{Name}StoreRequest.php — Validation request for storing.
  • app/Http/Requests/{Name}UpdateRequest.php — Validation request for updating.
  • app/Http/Controllers/API/{Name}Controller.php — API controller with:
  • index method supporting search (q), sort (sortField, sortOrder), and pagination (sizePerPage).
  • store, show, update, destroy methods.

Features

  • Standardized API scaffolding reduces repetitive boilerplate code.
  • Soft deletes enabled by default.
  • Search, sort, paginate support out of the box.
  • JSON validation error responses for API-friendly error handling.
  • Clean, maintainable, and easy to customize generated code.

Example

php artisan make:api Product

Generates Product API scaffolding:

  • Model: app/Models/Product.php
  • Migration: database/migrations/xxxx_xx_xx_create_products_table.php
  • Requests: ProductStoreRequest, ProductUpdateRequest
  • Controller: app/Http/Controllers/API/ProductController.php

Authors

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

Please review our security policy on how to report security vulnerabilities.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.