marcolamr / router
Create and manage your routes easy, fast and extremely uncomplicated.
v1.0.0
2022-09-02 17:38 UTC
Requires
- php: >=8.1
README
Small, simple and uncomplicated. The router is a PHP routing component with abstraction for MVC. Prepared with RESTfull verbs (GET, POST, PUT and DELETE), it works in its own layer in isolation and can be seamlessly integrated into your application.
Pequeno, simples e descomplicado. O router é um componente de rotas PHP com abstração para MVC. Preparado com verbos RESTfull (GET, POST, PUT e DELETE), trabalha em sua própria camada de forma isolada e pode ser integrado sem segredos a sua aplicação.
Highlights
- Simple installation (Instalação simples)
- Works with standard php server: php -S localhost:8000 (Funciona com php server padrão)
- Composer ready and PSR-2 compliant (Pronto para o composer e compatível com PSR-2)
Installation
Router is available via Composer:
"marcolamr/router": "^1.0"
or run
composer require marcolamr/router
Documentation
Getting Started:
<?php require __DIR__ . "/vendor/autoload.php"; use MarcolaMr\Router\Response; use MarcolaMr\Router\Router; define("URL", "http://localhost:8000"); $router = new Router(URL); $router->get("/", [ function() { return new Response(200, "Hello World"); } ]); $router->get("/controller", [ function() { return new Response(200, Controller::method()); } ]); $router->get("/{id}", [ function($id) { return new Response(200, var_dump($id)); } ]); $router->run()->sendResponse();