Skip to content

Latest commit

 

History

History
33 lines (28 loc) · 575 Bytes

README.md

File metadata and controls

33 lines (28 loc) · 575 Bytes

zend-httperrors

Http compliant error reporting structure for zend framework.

composer require phphacks/zend-httperrors

Add to your modules.config.php

return [
  'Zend\HttpErrors',
  'My\Other\Modules'
];

Then throw an HttpErrorException

class MyController
{
   private $auth;
   
   public function __construct(AuthorizationService $auth)
   {
      $this->auth = $auth;
   }
   
   public function doSomethingAction()
   {
      if(!$auth->isAuthorized()) {
         throw new HttpUnauthorizedException();
      }
   }
}

That's just it.