consoletvs/apify
Composer 安装命令:
composer require consoletvs/apify
包简介
API generator for laravel 5
README 文档
README
API generator for Laravel 5
Table Of Contents
Installation
To install apify use composer
Download
composer require consoletvs/apify
Add service provider & alias
Add the following service provider to the array in: config/app.php
ConsoleTVs\Apify\ApifyServiceProvider::class,
Publish the assets
php artisan vendor:publish
Configuration
To configure the package go to: config/apify.php
The default file have a valid example and it's documented, check it out, should look like this:
<?php return [ /* |-------------------------------------------------------------------------- | Prefix used to access the API |-------------------------------------------------------------------------- */ 'prefix' => 'apify', /* |-------------------------------------------------------------------------- | Enables or disabled the whole API endpoints |-------------------------------------------------------------------------- */ 'enabled' => true, /* |-------------------------------------------------------------------------- | The tables enabled for the api and it's columns |-------------------------------------------------------------------------- */ 'tables' => [ // Specify all the tables below 'users' => [ // The columns from the table that will be displayed in the JSON 'id', 'name', 'email', 'created_at', 'updated_at' ], ], ];
Usage
Visit the endpoint like this:
Website URL + /api/ + Prefix + /{table}/{accessor?}/{data?}
table: is the table you want to look at, must be an index of the table array in the configuration.
accessor: is optional, and it's the colum to filter data.
data: is the data you're filtering, you can add multiple data separated with a ,
Note: Remember that all calls to the API goes first to the api middleware, if you need to modify the api throttle go to: App\Http\Kernel.php and modify the api throttle.
'api' => [ 'throttle:60,1', 'bindings', ],
The 60 determines the max calls / minute.
The 1 determines the minutes to wait if the max calls are exceded.
Some examples:
http://localhost/web/Laralum3/public/api/apify/users (example URL)
{"users":[{"id":1,"name":"\u00c8rik Campobadal","email":"ConsoleTVs@gmail.com","created_at":"2016-09-22 16:13:28","updated_at":"2016-10-02 11:18:25"},{"id":2,"name":"Second User","email":"ConsoleTV2s@gmail.com","created_at":"2016-09-21 16:13:28","updated_at":"2016-09-22 16:20:00"},{"id":3,"name":"Third User","email":"ConsoleTV3s@gmail.com","created_at":"2016-08-22 16:13:28","updated_at":"2016-09-22 16:20:00"}]}
http://localhost/web/Laralum3/public/api/apify/users/email/ConsoleTVs@gmail.com,ConsoleTV3s@gmail.com (example URL)
{"users":[{"id":1,"name":"\u00c8rik Campobadal","email":"ConsoleTVs@gmail.com","created_at":"2016-09-22 16:13:28","updated_at":"2016-10-02 11:18:25"},{"id":3,"name":"Third User","email":"ConsoleTV3s@gmail.com","created_at":"2016-08-22 16:13:28","updated_at":"2016-09-22 16:20:00"}]}
consoletvs/apify 适用场景与选型建议
consoletvs/apify 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 75 次下载、GitHub Stars 达 26, 最近一次更新时间为 2016 年 11 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 consoletvs/apify 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 consoletvs/apify 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 75
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-09