phphacks/zend-httperrors

v1.0.5 2020-09-25 19:07 UTC

This package is not auto-updated.

Last update: 2024-04-20 13:53:36 UTC


README

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.