API starter project: ublaboo/api-router-project

před rokem

Pavel Janda
Člen | 783
+
+5
-

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 implement IPresenter
  • 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 ApiResponse implementing Application\IResponse even though it's only extending JsonResponse (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)

před rokem

David Grudl
founder | 6745
+
0
-

Could you send things like this here too, to let it not be lost in the forum?

(thx @JanTvrdík, link fixed)

před 11 měsíci

Tomáš Votruba
Moderator | 1149
+
0
-

To make code even lighter, you can use controllers without dependency on IPresenter at all: https://www.tomasvotruba.cz/…ith-freedom/