saleh/smart-api-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

saleh/smart-api-generator

最新稳定版本:v1.0.0

Composer 安装命令:

composer require saleh/smart-api-generator

包简介

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

README 文档

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.

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-06