定制 berrygoudswaard/cakephp-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

berrygoudswaard/cakephp-api

最新稳定版本:4.2.0

Composer 安装命令:

composer require berrygoudswaard/cakephp-api

包简介

关键字:

README 文档

README

This plugin contains a component that make it easier to create API output with CakePHP

Requirements

  • CakePHP 3.1+

Installation

composer require berrygoudswaard/cakephp-api

Usage

In your app's config/bootstrap.php add:

Plugin::load('BerryGoudswaard/Api');

Then load the component where you need it by adding the following code to your controller:

$this->loadComponent('BerryGoudswaard/Api.Api', [
    'cors' => [
        'allowHeaders' => ['Content-Type', 'Authorization'],
        'allowMethods' => ['GET', 'POST', 'PUT', 'DELETE'],
        'allowOrigins' => ['http://localhost:4200', 'http://www.berrygoudswaard.nl'],
        'allowCredentials' => 'true',
    ]
]);

Output data

public function index()
{
    $tags = $this->Tags->find();

    $this->Api->addData('tags', $tags);
    return $this->Api->output();
}

The code above will output something like:

{
    "message": "OK",
    "code": 200,
    "data": {
        "tags": {
            "items": [
                {
                    "id": 1,
                    "tag": "cakephp"
                }, {
                    "id": 2,
                    "tag": "plugin"
                }
            ]
        }
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固