Phalcon Tutorial
Phalcon Useful Resources
Selected Reading
- Phalcon - Security Features
- Phalcon - Object Document Mapper
- Phalcon - Working with Forms
- Phalcon - Asset Management
- Phalcon - Multi-Lingual Support
- Phalcon - Session Management
- Phalcon - Cookie Management
- Phalcon - Database Migration
- Phalcon - Query Language
- Phalcon - Scaffolding Application
- Phalcon - Switching Databases
- Phalcon - Database Connectivity
- Phalcon - Routing
- Phalcon - Views
- Phalcon - Models
- Phalcon - Controllers
- Phalcon - Configuration
- Phalcon - Functionality
- Phalcon - Application Structure
- Phalcon - Environmental Setup
- Phalcon - Overview
- Phalcon - Home
Phalcon Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Phalcon - Routing
Phalcon - Routing
The router component allows to define routes that are mapped to the controllers or handlers that should receive the request. A router parses a URI as per the information received.
Every router in the web apppcation has two modes −
MVC mode
Match-only mode
The first mode is ideal for working with MVC apppcations. Following is the syntax to define a route in Phalcon.
$router = new Router(); // Define a route $router->add( "<URI-Name>", [ "controller" => "<controller-name>", "action" => "<action-name>", ] );
Example
For searching a category, let us create a route in routes.php of config folder.
Consider creating a route which will call a method login as we invoke “UsersController”. In such a case, it is suggested to create a route which maps the given URL.
<?php $router = new PhalconMvcRouter(); $router->add( /login , array( controller => users , action => login , )); return $router;
Output
The code will produce the following output −
Advertisements