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
Requires
- php: >=8.3.0
- papi/papi: ^2.1.0
- papimod/common: ^2.1.0
- papimod/dotenv: ^2.1.0
Requires (Dev)
- phpunit/phpunit: ^12.5.2
- squizlabs/php_codesniffer: ^4.0.1
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); } }