averay / http-exceptions
Discrete exceptions for all HTTP error status code for use in a server application.
v1.0.0
2024-03-07 06:37 UTC
Requires
- php: >=8.2
- fig/http-message-util: ^1.1
Requires (Dev)
- vimeo/psalm: ^5.22
README
Discrete exceptions for all HTTP error status code for use in a server application.
Example
<?php // ... if ($item === null) { throw new HttpNotFoundException('Unknown item.'); } if ($user === null) { throw new HttpUnauthorizedException('User not logged in.'); } if (!$user->hasAccess($item)) { throw new HttpForbiddenException('User does not have access to item.'); } // ...