Vökuró is another sample application you can use to learn more about Phalcon. Vökuró is a small website that shows how to implement a security features and management of users and permissions. You can clone its code from GitHub.
Una vez clonado el proyecto en la raíz de tu documento, podrá ver la siguiente estructura:
This project follows a quite similar structure to INVO. Once you open the application in your browser https://localhost/vokuro you’ll see something like this:
The application is divided into two parts, a frontend, where visitors can sign up the service and a backend where administrative users can manage registered users. Both frontend and backend are combined in a single module.
Load Classes and Dependencies
This project uses Phalcon\Loader to load controllers, models, forms, etc. within the project and composer to load the project’s dependencies. So, the first thing you have to do before execute Vökuró is install its dependencies via composer. Assuming you have it correctly installed, type the following command in the console:
Vökuró sends emails to confirm the sign up of registered users using Swift, the composer.json looks like:
Now, there is a file called app/config/loader.php where all the auto-loading stuff is set up. At the end of this file you can see that the composer autoloader is included enabling the application to autoload any of the classes in the downloaded dependencies:
<?php// ...// Use composer autoloader to load vendor classesrequire_onceBASE_PATH.'/vendor/autoload.php';
Moreover, Vökuró, unlike the INVO, utilizes namespaces for controllers and models which is the recommended practice to structure a project. This way the autoloader looks slightly different than the one we saw before (app/config/loader.php):
Instead of using registerDirectories(), we use registerNamespaces(). Every namespace points to a directory defined in the configuration file (app/config/config.php). For instance the namespace Vokuro\Controllers points to app/controllers so all the classes required by the application within this namespace requires it in its definition:
This action simply pass a form instance of SignUpForm to the view, which itself is rendered to allow the user enter the login details: