A lightweight and flexible router for the Luminar Framework

dev-main 2024-10-18 16:48 UTC

This package is auto-updated.

Last update: 2025-04-18 17:58:43 UTC


README

Tests Status

The Luminar Router is a lightweight routing component for the Luminar PHP framework. It allows you to define and manage routes in your application, supporting dependency injection and advanced route handling.

Installation

Install via Composer:

composer require luminar-organization/router

Basic Usage

Defining Routes

You can define routes using the Route annotation, specifying the HTTP method, the route pattern.

namespace App\Controllers;

use Luminar\Http\Controller\AbstractController;
use Luminar\Http\Response;

class ExampleController extends AbstractController
{
    public static string $response = "Hello World";

    #[Route("/example", methods: "GET")]
    public function index(): Response
    {
        return $this->text($this::$response);
    }
}

Handling Requests

To handle incoming HTTP requests, use the dispatch method

$response = $router->dispatch($_SERVER["REQUEST_METHOD"], $_SERVER["REQUEST_URI"]);

License

This package is open-sourced software licensed under the MIT License

This README provides an overview of how to use the luminar-organization/router component in your projects. It covers installation, basic routing.