# Apitte Presenter

Integrate Apitte into nette/routing with a presenter.

Usage of that package is not recommended as it requires unnecessary conversion of nette request into psr-7 request. It also adds headers from nette response configuration which are usually mean for UI, not an API.

Presenter is currently incompatible with middlewares.

# Content

# Setup

First of all, setup core package.

Install apitte/presenter

composer require apitte/presenter
1

Configure presenter mapping

application:
    mapping:
        Apitte: Apitte\Presenter\*Presenter
1
2
3

Prepend ApiRoute to your router. Therefore you can reach your API at <project>/api.

namespace App\Router;

use Apitte\Presenter\ApiRoute;
use Nette\Application\IRouter;
use Nette\StaticClass;

class RouterFactory
{
    use StaticClass;

    public static function createRouter(): IRouter
    {
        $router = new RouteList;
        $router[] = new ApiRoute('api');
        $router[] = new Route('<presenter>/<action>', 'Homepage:default');
        return $router;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

In index.php drop Apitte\Core\Application\IApplication and keep Nette\Application\Application only.