# Tutorial 6: Vökuró
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](https://github.com/phalcon/vokuro).
## Project Structure
Once you clone the project in your document root you’ll see the following structure:
~~~
vokuro/
app/
config/
controllers/
forms/
library/
models/
views/
cache/
public/
css/
img/
schemas/
~~~
This project follows a quite similar structure to INVO. Once you open the application in your browser[http://localhost/vokuro](http://localhost/vokuro)you’ll see something like this:
![../_images/vokuro-1.png](http://docs.iphalcon.cn/_images/vokuro-1.png)
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](http://docs.iphalcon.cn/api/Phalcon_Loader.html)to load controllers, models, forms, etc. within the project and[composer](https://getcomposer.org/)to load the project’s dependencies. So, the first thing you have to do before execute Vökuró is install its dependencies via[composer](https://getcomposer.org/). Assuming you have it correctly installed, type the following command in the console:
~~~
cd vokuro
composer install
~~~
Vökuró sends emails to confirm the sign up of registered users using Swift, the composer.json looks like:
~~~
{
"require" : {
"php" : ">=5.5.0",
"ext-phalcon" : ">=3.0.0",
"swiftmailer/swiftmailer" : "^5.4",
"amazonwebservices/aws-sdk-for-php" : "~1.0"
}
}
~~~
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 classes
require_once BASE_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):
~~~
<?php
use Phalcon\Loader;
$loader = new Loader();
$loader->registerNamespaces(
[
"Vokuro\\Models" => $config->application->modelsDir,
"Vokuro\\Controllers" => $config->application->controllersDir,
"Vokuro\\Forms" => $config->application->formsDir,
"Vokuro" => $config->application->libraryDir,
]
);
$loader->register();
// ...
~~~
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:
~~~
<?php
namespace Vokuro\Controllers;
class AboutController extends ControllerBase
{
// ...
}
~~~
## Sign Up
First, let’s check how users are registered in Vökuró. When a user clicks the “Create an Account” button, the controller SessionController is invoked and the action “signup” is executed:
~~~
<?php
namespace Vokuro\Controllers;
use Vokuro\Forms\SignUpForm;
class RegisterController extends ControllerBase
{
public function signupAction()
{
$form = new SignUpForm();
// ...
$this->view->form = $form;
}
}
~~~
This action simply pass a form instance of SignUpForm to the view, which itself is rendered to allow the user enter the login details:
~~~
{{ form("class": "form-search") }}
<h2>
Sign Up
</h2>
<p>{{ form.label("name") }}</p>
<p>
{{ form.render("name") }}
{{ form.messages("name") }}
</p>
<p>{{ form.label("email") }}</p>
<p>
{{ form.render("email") }}
{{ form.messages("email") }}
</p>
<p>{{ form.label("password") }}</p>
<p>
{{ form.render("password") }}
{{ form.messages("password") }}
</p>
<p>{{ form.label("confirmPassword") }}</p>
<p>
{{ form.render("confirmPassword") }}
{{ form.messages("confirmPassword") }}
</p>
<p>
{{ form.render("terms") }} {{ form.label("terms") }}
{{ form.messages("terms") }}
</p>
<p>{{ form.render("Sign Up") }}</p>
{{ form.render("csrf", ["value": security.getToken()]) }}
{{ form.messages("csrf") }}
<hr>
{{ endForm() }}
~~~
- 简介
- 安装
- 安装(installlation)
- XAMPP下的安装
- WAMP下安装
- Nginx安装说明
- Apache安装说明
- Cherokee 安装说明
- 使用 PHP 内置 web 服务器
- Phalcon 开发工具
- Linux 系统下使用 Phalcon 开发工具
- Mac OS X 系统下使用 Phalcon 开发工具
- Windows 系统下使用 Phalcon 开发工具
- 教程
- 教程 1:让我们通过例子来学习
- 教程 2:INVO简介
- 教程 3: 保护INVO
- 教程4: 使用CRUD
- 教程5: 定制INVO
- 教程 6: Vökuró
- 教程 7:创建简单的 REST API
- 组件
- 依赖注入与服务定位器
- MVC架构
- 使用控制器
- 使用模型
- 模型关系
- 事件与事件管理器
- Behaviors
- 模型元数据
- 事务管理
- 验证数据完整性
- Workingwith Models
- Phalcon查询语言
- 缓存对象关系映射
- 对象文档映射 ODM
- 使用视图
- 视图助手
- 资源文件管理
- Volt 模版引擎
- MVC 应用
- 路由
- 调度控制器
- Micro Applications
- 使用命名空间
- 事件管理器
- Request Environmen
- 返回响应
- Cookie 管理
- 生成 URL 和 路径
- 闪存消息
- 使用 Session 存储数据
- 过滤与清理
- 上下文编码
- 验证Validation
- 表单_Forms
- 读取配置
- 分页 Pagination
- 使用缓存提高性能
- 安全
- 加密与解密 Encryption/Decryption
- 访问控制列表
- 多语言支持
- 类加载器 Class Autoloader
- 日志记录_Logging
- 注释解析器 Annotations Parser
- 命令行应用 Command Line Applications
- Images
- 队列 Queueing
- 数据库抽象层
- 国际化
- 数据库迁移
- 调试应用程序
- 单元测试
- 进阶技巧与延伸阅读
- 提高性能:下一步该做什么?
- Dependency Injection Explained
- Understanding How Phalcon Applications Work
- Api
- Abstract class Phalcon\Acl