Metrics
0
Watch 5 Star 5 Fork 0

天心流水 / cdoPHP

Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
A simple php router. spread retract

Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
readme.md

Central do

A simple php router designed for super tiny projects.

PATH_INFO Only.

Install

composer require takashiki/cdo

Demo

$do = new \Mis\Cdo();

$do->get('/', function () {
    echo 'hello world';
});

$do->post('/', function () {
    $name = isset($_POST['name']) ? $_POST['name'] : 'world';
    echo "hello {$name}";
});

$do->any('/(\d+)', function ($id) {
    echo $id;
});

/**
 * When using named subpattern, order of parameters is not matter.
 * eg. /book/2
 */
$do->any('/(?P<type>\w+)/(?P<page>\d+)', function ($page, $type) {
    echo $type.'<br>'.$page;
});

$do->run();

Or:

use Mis\Cdo;

Cdo::get('/', function () {
    echo 'hello world';
});

Cdo::run();

Comments ( 0 )

You need to Sign in for post a comment

Help Search