Skip to content

takashiki/cdo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();

About

A simple php router.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages