1. Go to this page and download the library: Download bloatless/endocore library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class MyHtmlAction extends HtmlAction
{
public function __invoke(array $arguments = []): Response
{
// some error occurs...
return $this->responder->error(['data' => 'some additional data...']);
}
}
class MyHtmlAction extends HtmlAction
{
public function __invoke(array $arguments = []): Response
{
return $this->responder->badRequest(); // 400
return $this->responder->notFound(); // 404
return $this->responder->methodNotAllowed(); // 405
}
}
class MyDomain
{
public function myMethod(): string
{
throw new EndocoreException('Something went wrong...');
}
}
class MyDomain
{
public function myMethod(): string
{
throw new BadRequestException(); // 400
throw new NotFoundException(); // 404
throw new MethodNotAllowedException(); // 405
}
}