O'Reilly logo

Learning Phalcon PHP by Calin Rada

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the module structure

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

Creating the module structure

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:

  1. Open the routing.php file from the api 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'); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required