1. Go to this page and download the library: Download memcrab/exceptions 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/ */
memcrab / exceptions example snippets
use memCrab\Router\Router;
use memCrab\Router\RouterException;
try {
# Initialize Router
$Router = new Router();
$Router->loadRoutesFromYaml("../src/routs.example.yaml");
# Routing
$Router->matchRoute("http://example.com/post/", "POST");
# Run your Controller|Service|Component
$ServiceName = $Router->getService();
$Service = new $ServiceName();
$Action = $Router->getAction();
$Response = $Service->$Action($Router->getParams());
}
catch(RouterException $error){
$Response = new \YourResponseClass();
$Response->setErrorResponse($error);
}
$Response->sendHeaders();
$Response->sendContent();