andreacivita/api-crud-generator
Composer 安装命令:
composer require andreacivita/api-crud-generator
包简介
Simple API Crud generator for Laravel
README 文档
README
Laravel | API CRUD Generator
This Generator package provides generators of Models, Controllers, Request, Routes & Tests for a painless development.
INSTALL
Install the package through Composer.
Run the Composer require command from the Terminal:
composer require andreacivita/api-crud-generator --dev
SETUP
Run this command from the Terminal
php artisan vendor:publish
Select andreacivita/api-crud-generator and setup it's complete.
USAGE
Managing all database
Usage of this package is very simple.
First, let's supposing I want to generate CRUD for all table in my db.
So, we run
php artisan make:crud --all
No further options required. Your setup is complete!
Interactive mode
You can manage a single table with interactive mode or manually (see next paragraph).
Just run
php artisan make:crud --interactive
Crud generator will ask you several data (Name of resource, Table name and use of timestamps).
Managing a single db table
Now i suppose generation of CRUD operations of Car db table.
Run this command:
php artisan make:crud Car
Done! You will have Car model (located in App/Model directory), CarController, CarRequest (used for input data) and Routes (located in routes/api.php).
OPTIONS
TABLE NAME
By default, DB Table's name is plural, while Model class name is singular (e.g. Table => Cars, Model => Car). You can change this behavior specifying the name in terminal
php artisan make:crud Car --table Car
This will create the same resources, but table name in model will be 'Car' (instead of default 'Cars')
TIMESTAMPS
By default, this packages will set all timestamps to false. You can change this doing this command:
php artisan make:crud Car --timestamps true
This will set 'timestamps=true' in Model class.
LARAVEL/PASSPORT INTEGRATION
By default, Routes will be not protected by passport. However, you can generate Passport-protected routes with:
php artisan make:crud Car --passport
This will set 'timestamps=true' in Model class.
ROUTING
Routes will follow Route::resource() Schema (default routing schema provided by Laravel).
Example: i'm generating Car crud
| Route | Method | Operation |
|---|---|---|
| car | GET | Get all cars |
| car/{id} | GET | Find car by id |
| car | POST | Insert a new car |
| car/{id} | PUT / PATCH | Update car by id |
| car/{id} | DELETE | Delete car by id |
Remember that all api routes have 'api/' prefix.
TESTING
When created CRUD structure (Controllers, Models, Request, Resource, Factory & Routes), this package generate Feature test file.
SETUP GENERATED CRUD
FACTORIES
Tests now require factory class to manipulate data. You should provide data schema into your factory class (using Faker), so you'll be able to test easily your API
VALIDATORS
Write better code will helps you so much! So, default behavior of Controllers is to force you to use validated data. You have to set all validation rules into your FormRequest class.
E.g. For Car Crud, you will set rules into your App\Request\CarRequest.php
CONTRIBUTING
This package is covered by MIT license. You are able to do whatever you want with this code.
Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities. You can see issues or enhancement and assign task for contributing :)
How can I thank you?
Star this repo or follow me on GitHub. And, if you want, you can share this link! :)
AUTHORS
This package has been originally developed by Andrea Civita
A special thanks goes to Bastianjoel for it's pull request
andreacivita/api-crud-generator 适用场景与选型建议
andreacivita/api-crud-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.25k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2018 年 12 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「crud」 「laravel」 「crud generator」 「API generator」 「laravel crud generator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 andreacivita/api-crud-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 andreacivita/api-crud-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 andreacivita/api-crud-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Gii Generator for double model generation
A PSR-7 compatible library for making CRUD API endpoints
Admin panel generator for Laravel 8 and based on Vuetify Admin, a separate SPA admin framework running on top of REST APIs.
Collection of tools to use the full power of the Enyalius framework
Laravel Admin CRUD Generator
统计信息
- 总下载量: 1.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-11