C:\xampp\htdocs\kptv2\admin2\vendor\phroute\phroute\examples\simple.php


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
<?php

include __DIR__ '/../vendor/autoload.php';

use 
Phroute\Phroute\RouteCollector;
use 
Phroute\Phroute\Dispatcher;

$collector = new RouteCollector();

$collector->get('/', function(){
    return 
'Home Page';
});

$collector->post('products', function(){
    return 
'Create Product';
});

$collector->put('items/{id}', function($id){
    return 
'Amend Item ' $id;
});

$dispatcher =  new Dispatcher($collector->getData());

echo 
$dispatcher->dispatch('GET''/'), "\n";   // Home Page
echo $dispatcher->dispatch('POST''/products'), "\n"// Create Product
echo $dispatcher->dispatch('PUT''/items/123'), "\n"// Amend Item 123
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586