Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 1.33 KB

README.md

File metadata and controls

55 lines (38 loc) · 1.33 KB

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

Configure presenter mapping

application:
    mapping:
        Apitte: Apitte\Presenter\*Presenter

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;
    }
}

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