Skip to content

A very simpler php router for use into your app facades or framework

Notifications You must be signed in to change notification settings

diegogit03/router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Router

A very simpler and without opnion router. is a good library for integrate with your framework.

basic usage

A simpler example of a json api:

<?php

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

use Diego03\Router\Router;

$router = new Router();

$router->get('/', function () {
    return [
        'message' => 'Hello World!'
    ];
});

$router->get('/users/:id', function ($id) {
    return [
        'id' => $id
    ];
});

$route = $router->match(
    $_SERVER['REQUEST_METHOD'],
    $_SERVER['REQUEST_URI']
);

echo json_encode(
    $route['handler'](
        ...$route['params']
    )
);

Feature roadmap

  • Support all basic http methods
  • path params
  • Group routing
  • Domain routing
  • Middlewares