https://github.com/randomstate/api
A flexible API package for PHP. Fits perfectly with Laravel and Laravel Doctrine.
https://github.com/randomstate/api
Last synced: 5 months ago
JSON representation
A flexible API package for PHP. Fits perfectly with Laravel and Laravel Doctrine.
- Host: GitHub
- URL: https://github.com/randomstate/api
- Owner: randomstate
- License: mit
- Created: 2017-08-28T22:43:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-09-03T14:38:02.000Z (over 4 years ago)
- Last Synced: 2025-03-07T19:06:43.358Z (about 1 year ago)
- Language: PHP
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# randomstate/api
A flexible API package for PHP. Fits perfectly with Laravel and Laravel Doctrine.
This is a barebones package that is agnostic to any given PHP application or framework.
As a result, there is a lot of legwork to wire up the different components to get started.
**Please see randomstate/laravel-api for an out-of-the-box integration with Laravel that does this
all for you.**
# Installation
`composer require randomstate/api`
# Basic Usage
## Input Transformation
```php
bind(MyOwnEntityFromSomewhere::class, MyOwnEntityFractalTransformer::class);
$switchboard = new Switchboard($resolver);
$manager->register(
new CollectionAdapter($switchboard),
new ItemAdapter($switchboard)
);
$data = new MyOwnEntityFromSomewhere;
$output = $manager->transform($data); // will use MyOwnEntityFractalTransformer via Fractal to transform the data
```