We have already created the basic structure in the previous chapters. The directory structure should look like this:

This is okay. What we need to do here is enable the routing and add some methods to BaseController
so that we can move forward. Let's start this process by performing the following steps:
Open the
routing.php
file from theapi
module, delete its content, and put in this code:<?php $versions = [ 'v1' => '/api/v1', 'v2' => '/api/v2' ]; $router->removeExtraSlashes(true); // Articles group $articles = new \Phalcon\Mvc\Router\Group(array( 'module' => 'api', 'controller' => 'articles' )); $articles->setPrefix($versions['v1'].'/articles'); $articles->addGet('', array( 'module' => 'api', 'controller' => 'articles', 'action' => 'list' )); $router->mount($articles);
Next, we add an array with the available versions of our API, and we tell the router to remove extra slashes. Therefore, a request to
/api/v1...