ilias/opherator

Package to handle requests

1.0.3 2024-09-18 23:32 UTC

This package is auto-updated.

Last update: 2024-09-19 00:00:13 UTC


README

Maintainer Package Source Code Software License

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;

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;
}