ilias / opherator
Package to handle requests
1.0.8
2024-10-17 12:10 UTC
Requires (Dev)
- phpunit/phpunit: ^11.2
This package is auto-updated.
Last update: 2024-11-17 12:16:51 UTC
README
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.
Installation
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
Usage
Step 1: Setup The Handler
Create a file to define your routes, for example, in your project root folder, routes.php
:
<?php use Ilias\Opherator\\Request; Request::setup();
Step 2: Use As Your Needs
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; }