steodec/router

This package is abandoned and no longer maintained. The author suggests using the humbrain/php-project package instead.

Router use by Micro Framework

2.2 2022-06-17 08:53 UTC

This package is auto-updated.

Last update: 2023-03-01 11:24:21 UTC


README

A simple anotation router for PHP8.

Installation

Use the package manager composer to install Router.

composer require Steodec\Router

Usage

index.php

namespace Steodec\App;

use Steodec\Router

/**
* @params string namespace
 */
RouterConfig::run("Steodec\Controllers");

controller.php

namespace Steodec\Controllers;

use Steodec\Router

class Home {
   
    #[Routes(method:'GET', path: "/")]
    public function index() {
        echo "Hello World";
    }
}

Documentation

The Route attribute can take several parameters

method: "GET" | "PUT" | "POST" | "DELETE"

path: it is a string "/" it can take parameters ": parameter"

Example: "/user/:id"

is_granted: Takes a string as a parameter, work if you have roles system

License

MIT