https://github.com/phphleb/api-multitool
A set of traits for creating an API
https://github.com/phphleb/api-multitool
Last synced: 11 months ago
JSON representation
A set of traits for creating an API
- Host: GitHub
- URL: https://github.com/phphleb/api-multitool
- Owner: phphleb
- License: mit
- Created: 2022-10-07T11:25:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-30T19:22:33.000Z (over 2 years ago)
- Last Synced: 2025-04-10T19:13:36.976Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
A set of useful traits for API implementation
=====================
  [-brightgreen.svg)](https://github.com/phphleb/hleb/blob/master/LICENSE)
Can be used either separately or in conjunction with the HLEB2 framework: [github.com/phphleb/hleb](https://github.com/phphleb/hleb)
The set represents independent traits, each of which implements highly specialized methods that are used in controllers.
### Installation
Using Composer
```bash
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
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**](https://hleb2framework.ru).
### Testing
API traits tested using [github.com/phphleb/api-tests](https://github.com/phphleb/api-tests)