Apitte
Modern PHP/PSR7 API framework build on top of Nette Framework
PHP/PSR-7
Prepared and developed with PHP-FIG PHP/PSR-7 in mind. Use familiar HTTP PSR-7 objects in your code and do not learn any proprietary solutions.
OpenAPI
Enjoy standardized REST APIs documentation in OpenAPI format and use famous Swagger API tools. Make your API discoverable in seconds.
Content negotiation
Represent output data in many forms. Develop with .debug
representation and download as .csv
or whatever else only by URL suffix change.
Middlewares
Develop rich API apps witch complex behaviour in simple and readable form by composing custom middlewares.
Fast debug
Find problems, log errors, dump variables and debug in seconds thanks to full Tracy library integration.
Dependency injection
Based on fully featured Nette Dependency Injection container. Make your apps simple readable and testable.
Open source
Released under MIT license. Fork it, modify it, use it in your way.
Nette Framework
Do you need rich API solution for your Nette Framework application? We prepared direct integration for you.
REST ready
Create fully customizable and validated rich REST APIs. Make more versions of your REST API in moments.
# Installation
Add to your current project using composer.
composer require apitte/fullstack
Or take a look at examples.
composer create-project --repository https://github.com/planette/playground
# Examples
# Simple controller
Just return data as array and let Apitte to create correct response for you.
/**
* @Controller
* @ControllerPath("/users")
* @ControllerId("users")
*/
final class UsersController extends BaseV2Controller
{
/**
* @Id("index")
* @Path("/")
* @Method("GET")
*/
public function index()
{
return [
['id' => 1, 'nick' => 'Chuck Norris'],
['id' => 2, 'nick' => 'Felix'],
];
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Prepared exceptions
Use prepared exceptions and send correct error codes as simple as possible.
<?php
/**
* @Controller
* @ControllerPath("/error")
*/
final class ErrorController extends BaseV1Controller
{
/**
* @Path("/client")
* @Method("GET")
*/
public function client()
{
throw ClientErrorException::create()
->withCode(403)
->withContext(['a' => 'b']);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Simple configuration
Configure middlewares, setup plugins and register controllers in few lines of code.
extensions:
middlewares: Contributte\Middlewares\DI\MiddlewaresExtension
resource: Contributte\DI\Extension\ResourceExtension
api: Apitte\Core\DI\ApiExtension
resource:
resources:
App\Controllers\:
paths: [%appDir%/controllers]
decorator:
inject: true
api:
plugins:
Apitte\Debug\DI\DebugPlugin:
Apitte\Middlewares\DI\MiddlewaresPlugin:
Apitte\Negotiation\DI\NegotiationPlugin:
unification: on
Apitte\Mapping\DI\MappingPlugin:
Apitte\OpenApi\DI\OpenApiPlugin:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19