saleh/smart-api-generator

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

Maintainers

Package info

github.com/sadik254/smart-api-generator

pkg:composer/saleh/smart-api-generator

Statistics

Installs: 7

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.1 2026-01-25 06:08 UTC

This package is auto-updated.

Last update: 2026-03-25 06:29:03 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
  • Generate Postman Collection with one command
  • 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

Run this artisan command to create the postman collection of all the existing models, if the collection contains the previous model data it won't duplicate rather safely skip that model:

php artisan smart-api:postman

You can specifically tell the artisan command to create specific model's collection using the following command

php artisan smart-api:postman User

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.