This PHP router system allows you to define and manage your application's routes in a simple and organized manner, inspired by Laravel's routing system.
To install the package, add it to your composer.json
file:
{
"require": {
"ilias/opherator": "1.0.0"
}
}
Or simply run the terminal command
composer require ilias/opherator
Then, run the following command to install the package:
composer install
Create a file to define your routes, for example, in your project root folder, routes.php
:
<?php
use Ilias\Opherator\\Request;
Request::setup();
The handler provides the next methods:
class Request
{
public static function getMethod() : string;
public static function getBody(): array;
public static function getQuery(): array;
public static function hasBody(): bool;
}
And the Response
provides:
class Response
{
public static function setResponse(array $response): void;
public static function appendResponse(string $key = "data", string|array $response, bool $override = true): void;
public static function jsonResponse(): void;
public static function htmlResponse(): void;
public static function answer(): void;
}