API starter project: ublaboo/api-router-project
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.

- Pavel Janda
- Člen | 977
Many people asked me for help with starting a API built on top of nette
framework. Also there have been some people asking for a sandbox-like repo with
ublaboo/api-router. So there it happend – a really small and
easy-to-read starter project release on github.
Some basic ideas I implemented in first 6 minutes each time I started a
nette/web-project in a API app:
- Do not use
UI\Presneter, just implementIPresenter - Also don't call these endpoints Presenters but Controllers :P
- No need to use RobotLoader + stick to psr-4
- Put the response payload formatting logic somewhere else then
BasePresenter.. - Let there be a
ApiResponseimplementingApplication\IResponseeven though it's only extendingJsonResponse(for now) and not doing anything special. But it could in future – add some special headers, do not use JSON, but XML (haha), or something like that
So hey, 6 minutes are over, it's time for you to try it out now:
composer create-project ublaboo/api-router-project httpApi
Editoval Pavel Janda (3. 7. 2017 11:11)

- David Grudl
- Nette Core | 8296
Could you send things like this here too, to let it not be lost in the forum?
(thx @JanTvrdík, link fixed)

- Tomáš Votruba
- Moderator | 1114
To make code even lighter, you can use controllers without dependency on
IPresenter at all: https://www.tomasvotruba.cz/…ith-freedom/