PHP code example of memcrab / exceptions

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();

- apt-get update
- apt-get install php-pear
- apt-get install php-dev
- apt-get install php-xml php7.0-xml
- apt-get install libyaml-dev
- pecl channel-update pecl.php.net
- pecl install yaml-2.0.0

- brew install php71 --with-pear
- brew install autoconf
- touch $(brew --prefix php71)/lib/php/.lock && chmod 0644 $(brew --prefix php71)/lib/php/.lock
- pecl install yaml-2.0.0