pokeb / php-mvc-router

Lightweight Rails-style MVC router for PHP

php-mvc-router / controllers / projects_controller.php
100644 35 lines (28 sloc) 0.668 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
 
/*
An example of a simple controller using views
*/
 
class projects_controller extends controller {
 
// GET /projects
function index() {
require_once("views/projects/index.php");
exit;
}
 
// GET /projects/1234
function view($project) {
require_once("views/projects/project.php");
exit;
}
 
// GET /projects/1234/delete
function delete($project) {
//This is just an example, so it doesn't actually delete anything
$project->delete();
header("Location: /projects");
exit;
}
 
// GET //projects/1234/items/567
function view_item($project,$item) {
require_once("views/projects/item.php");
exit;
}
 
}