- FuelPHP Tutorial
- FuelPHP - Home
- FuelPHP - Introduction
- FuelPHP - Installation
- FuelPHP - Architecture Overview
- FuelPHP - Simple Web Application
- FuelPHP - Configuration
- FuelPHP - Controllers
- FuelPHP - Routing
- FuelPHP - Requests & Response
- FuelPHP - Views
- FuelPHP - Presenters
- FuelPHP - Models & Database
- FuelPHP - Form Programming
- FuelPHP - Validation
- Advanced Form Programming
- FuelPHP - File Uploading
- FuelPHP - Ajax
- FuelPHP - HMVC Request
- FuelPHP - Themes
- FuelPHP - Modules
- FuelPHP - Packages
- Cookie & Session Management
- FuelPHP - Events
- FuelPHP - Email Management
- FuelPHP - Profiler
- Error Handling & Debugging
- FuelPHP - Unit Testing
- Complete Working Example
- FuelPHP Useful Resources
- FuelPHP - Quick Guide
- FuelPHP - Useful Resources
- FuelPHP - Discussion
FuelPHP - HMVC Request
FuelPHP provides an excellent feature to request an action inside the same application using Request class. This is called HMVC Request. It enables to reuse the controller logic.
Creating a HMVC Request
Creating a HMVC request is as simple as creating a request object with the required URL and call the execute method as follows.
$list = Request::forge('employee/list/')->execute(); echo $list; $employee = Request::forge('employee/show/1')->execute(array('id' => '1')); echo $employee;
Working Example
Let us create a new controller, Controller_HMVC to test the HMVC feature. Create a file, fuel/app/classes/controller/hmvc.php and place the following code.
<?php class Controller_HMVC extends Controller { public function action_index() { echo Request::forge('employee/list')->execute(); } }
Here, we have just called the employee/list page through HMVC request and shown the result.
Result
Advertisements