phphleb/api-multitool
最新稳定版本:v2.0.0
Composer 安装命令:
composer require phphleb/api-multitool
包简介
A set of traits for creating an API
关键字:
README 文档
README
Can be used either separately or in conjunction with the HLEB2 framework: github.com/phphleb/hleb
The set represents independent traits, each of which implements highly specialized methods that are used in controllers.
Installation
Using Composer
composer require "phphleb/api-multitool:^2.0"
or download the library to the 'vendor/phphleb/api-multitool' folder.
BaseApiTrait
All auxiliary traits are collected in the trait BaseApiTrait as a set. Therefore, it is enough to connect it to the controller and get a complete implementation. If another set of these traits is needed, then you need to either use them as a group or combine them into your own set. It is best to include such a trait in the parent class of controllers that implement the API, so as not to have to do this for everyone.
For the HLEB2 framework it might look like this (implementation example):
<?php // File /app/Controllers/Api/BaseApiActions.php namespace App\Controllers\Api; use Hleb\Base\Controller; use Phphleb\ApiMultitool\BaseApiTrait; class BaseApiActions extends Controller { // Adding a set of traits for the API. use BaseApiTrait; function __construct(array $config = []) { parent::__construct($config); // Passing the debug mode value to the API constructor. $this->setApiBoxDebug($this->container->settings()->isDebug()); } }
After this, all controllers inheriting from this class will have methods from each trait in the set.
More details can be found in the framework documentation.
Testing
API traits tested using github.com/phphleb/api-tests
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-07