klisica/api-formula
Composer 安装命令:
composer require klisica/api-formula
包简介
Laravel API architecture builder based on artisan commands.
README 文档
README
Laravel API architecture builder based on artisan commands.
This package provides a nice and fluent way to generate combined controllers, models, migrations, requests, resources, repositories and services, thus keeping the code well structured and organized.
Installation
Install the package with composer, execute the setup command and register the RepositoryServiceProvider.php file in config > app.php under the providers array.
composer require klisica/api-formula
php artisan api-formula:setup
'providers' => [ ... App\Providers\RepositoryServiceProvider::class, ... ],
Next, in routes > api.php add // @API_FORMULA_AUTOIMPORT comment in order to enable auto importing of resource routes. For example, I like to bind the importing in middleware group:
... Route::midleware('auth:sanctum')->group(function () { Route::resource('job_posts', 'JobPostController')->parameters(['' => 'job_post']); ... // @API_FORMULA_AUTOIMPORT });
To publish the config file run:
php artisan vendor:publish --provider="KLisica\ApiFormula\Providers\ApiFormulaServiceProvider"
Usage
⭐ To start the API builder run the following command:
php artisan api-make:formula
To manually create specific file you can use one of these commands:
php artisan api-make:model ModelName php artisan api-make:migration create_example_table php artisan api-make:repository RepositoryName --model=ModelName php artisan api-make:service ServiceName php artisan api-make:request RequestName php artisan api-make:controller ControllerName --model=ModelName
Other external packages used with this package:
Filtering and sorting on models
Each model is using a custom Filterable trait, which is handling simple query-based filtering and sorting functions on models.
- Filters are accepted in format
column[operator]=value. - To filter by relations the format is
relationName|column[operator]=value(note the|separator in between). - Free-text filter is by default
_textquery parameter.
JSON example:
{ page: 1, per_page: 10, sort_by: ['created_at', 'desc'], 'name[equal]': 'Name example', 'relation|name[equal]': 'Relation name example', '_text': 'Search for something' 74 }
Raw URL-Query example:
http://api-formula.test/api/job_posts?per_page=10&page=1&sort_by[0]=created_at&sort_by[1]=desc&name[equal]=Name example&relation|name[equal]=Relation name example
klisica/api-formula 适用场景与选型建议
klisica/api-formula 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 280 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 01 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 klisica/api-formula 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 klisica/api-formula 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 280
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-01-03