In this book, we used a configuration file for the router. If you come from Symfony, for example, you might want to use annotations. For this, you need to change the router information in the DI:
<?php use Phalcon\Mvc\Router\Annotations; $di['router'] = function() { $router = new Annotations(false); $router->addResource('Articles', '/api/v1/articles'); return $router; };
Then you must modify ArticlesController
to look like this:
<?php namespace App\Api\Controllers; /** * @RoutePrefix("/api/v1/articles") */ class ArticlesController extends BaseController { /** * @Get("/") */ public function listAction() { } }
You can read more about the Annotation router at http://docs.phalconphp.com/en/latest/reference/routing.html#annotations-router. If you need/want, you can also develop your own router, implementing Phalcon\Mvc\RouterInterface
.