jlanger/router

v3.2.1 2020-10-19 09:25 UTC

This package is auto-updated.

Last update: 2024-09-19 18:01:46 UTC


README

This project implements a very simple Router based in php.

The configuration for it looks like this:

{
  "/homepage": {
    "GET": "homepage.php"
  },
  "/other_page": {
    "*": "other_page.php"
  }
}

This will allow only get methods on /homepage and all methods on /other-page.

All paths in the configuration must be relative to the index document mentioned in the usage section.

Usage

<?php

include 'vendor/autoload.php';

use JLanger\Router\Router;
use JLanger\Router\JsonRouteStorage;

(new Router(new JsonRouteStorage('config_file.json')))->doRouting($_SERVER);