saleh/smart-api-generator

Laravel package to auto-generate API scaffolding (model, migration, controller, routes)

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/saleh/smart-api-generator

v1.0.0 2025-08-06 20:00 UTC

This package is auto-updated.

Last update: 2026-01-07 08:54:08 UTC


README

Latest Version
License Latest Version on Packagist Total Downloads

A Laravel package to quickly generate API scaffolding — model, migration, controller, and routes — with customizable fields and validation, saving you repetitive work.

Features

  • Generate Eloquent Model with fillable properties
  • Generate Migration with nullable or required fields
  • Generate RESTful API Controller with full CRUD methods
  • Auto-append API resource routes with proper controller imports
  • Validation rules auto-generated based on field types and requirements
  • Simple artisan command interface

Installation

Require the package via Composer:

composer require saleh/smart-api-generator

Laravel will auto-discover the service provider.

Usage

Run the artisan command and follow the prompts:

php artisan make:smart-api {ModelName}

Example:

php artisan make:smart-api Post

When prompted to enter fields, use the format:

title:string:req, body:text, published_at:datetime
  • Append :req to mark a field as required (validation and migration NOT nullable)

  • Omit :req to make the field nullable

What it Generates

  • Model with $fillable properties
  • Migration with specified fields (nullable or required)
  • Controller with API resource methods: index, show, store, update, destroy
  • Routes added automatically in routes/api.php with proper controller import

Example Generated Controller Store Validation

$request->validate([
    'title' => 'required|string|max:255',
    'body' => 'nullable|string',
    'published_at' => 'nullable|date',
]);

License

This package is open-sourced software licensed under the MIT license

Contributing

Feel free to open issues or submit pull requests for improvements!

Author

Md. Saleh Sadik — GitHub — sadik254@gmail.com

Important

I am really new to this kind of publishing, any kind of suggesstion is welcome.