papimod/http-error

Module Papi

Installs: 7

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/papimod/http-error

v2.1.0 2025-12-22 15:16 UTC

This package is auto-updated.

Last update: 2025-12-22 15:29:47 UTC


README

Description

Help integrate error and warning handling into your papi.

This module is based on the official tutorial.

⚠︎ We advise against modifying the configuration of the “common module

Prerequisites Modules

Configuration

ENVIRONMENT (.ENV)

Required No
Type PRODUCTION, DEVELOPMENT, TEST or null
Description Display error details when is not set to PRODUCTION
Default null

Usage

You can add the following options to your .env file:

ENVIRONMENT=DEVELOPMENT

Import the module when creating your application:

require __DIR__ . "/../vendor/autoload.php";

use Papi\PapiBuilder;
use Papimod\Dotenv\DotEnvModule;
use Papimod\Common\CommonModule;
use Papimod\HttpError\HttpErrorModule;
use function DI\create;

$builder = new PapiBuilder();

$builder
    ->setModule(
        DotEnvModule::class, # Prerequisite
        CommonModule::class,
        HttpErrorModule::class
    )
    ->build()
    ->run();

Use one of the following exceptions whenever you want:

use Papi\abstract\PapiGet;
use Papimod\HttpError\exception\NotImplementedException;
use Slim\Psr7\Request;
use Slim\Psr7\Response;

final class NotImplementedGet extends PapiGet
{
    public static function getPattern(): string
    {
        return "/notImplemented";
    }

    public function __invoke(Request $request, Response $response): Response
    {
        throw new NotImplementedException($request);
    }
}