composer require apitte/core
1

Register DI extension

extensions:
    api: Apitte\Core\DI\ApiExtension

api:
    debug: %debugMode%
    catchException: true # Sets if exception should be catched and transformed into response or rethrown to output (debug only)
1
2
3
4
5
6

Create entry point

// www/index.php

use Apitte\Core\Application\IApplication;
use App\Bootstrap;

require __DIR__ . '/../vendor/autoload.php';

Bootstrap::boot()
    ->createContainer()
    ->getByType(IApplication::class)
    ->run();
1
2
3
4
5
6
7
8
9
10
11

# Usage in combination with nette application

// www/index.php

use Apitte\Core\Application\IApplication as ApiApplication;
use App\Bootstrap;
use Nette\Application\Application as UIApplication;

require __DIR__ . '/../vendor/autoload.php';

$isApi = substr($_SERVER['REQUEST_URI'], 0, 4) === '/api';
$container = Bootstrap::boot()->createContainer();

if ($isApi) {
    $container->getByType(ApiApplication::class)->run();
} else {
    $container->getByType(UIApplication::class)->run();
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# Add some plugins

# Decorators

Transform all requests and responses with single class.

See decorators chapter for more info.

# Mapping

Validate request parameters, map request body to entity and entity to response body.

See mapping chapter for more info.

# Middlewares

PSR-7 middlewares integration

Based on contributte/middlewares (opens new window), integrated by apitte/middlewares (opens new window).

See apitte/middlewares docs (opens new window) for more info.

# Negotiation

Transforms data into format requested in Accept header and in url suffix (/api/v1/users.xml)

See apitte/negotiation docs (opens new window) for more info.

# Debug

Debug api easily with negotiation (opens new window) extension and display Tracy debug bar (opens new window) along with dumped response data.

See apitte/debug docs (opens new window) for more info.

# Schema

Core plugin (enabled by default) which manage building and validation of whole api schema.

See schema chapter for more info.

# OpenApi

OpenApi (opens new window) integration with Swagger UI (opens new window) support.

See apitte/openapi docs (opens new window) for more info.

# Console

Console commands for your api.

Based on symfony/console (opens new window)

See apitte/console docs (opens new window) for more info.

# Presenter

Route into your api through a single nette route and presenter.

See apitte/presenter docs (opens new window) for more info.

# Implementing own plugins

api:
    plugins:
        App\Api\Plugin\YourAmazingPlugin:
1
2
3
namespace App\Api\Plugin;

use Apitte\Core\DI\Plugin\Plugin;

class YourAmazingPlugin extends Plugin
{

    public static function getName() : string
    {
        return 'pluginName';
    }

    // Add new services, override existing or whatever you want
    // Take a look at existing plugins for inspiration

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16