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:
routing.phpfile from the
apimodule, 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'); ...