phphacks / zend-httperrors
v1.0.5
2020-09-25 19:07 UTC
Requires
- zendframework/zend-mvc: ^3.1
- zendframework/zend-mvc-console: ^1.1.10
Requires (Dev)
- phpunit/phpunit: ^7.2
This package is not auto-updated.
Last update: 2024-09-21 15:38:35 UTC
README
为zend框架提供符合HTTP规范的错误报告结构。
composer require phphacks/zend-httperrors
添加到您的 modules.config.php 文件中
return [ 'Zend\HttpErrors', 'My\Other\Modules' ];
然后抛出 HttpErrorException
class MyController { private $auth; public function __construct(AuthorizationService $auth) { $this->auth = $auth; } public function doSomethingAction() { if(!$auth->isAuthorized()) { throw new HttpUnauthorizedException(); } } }
就是这样。