PHP code example of sikker / phinatra

1. Go to this page and download the library: Download sikker/phinatra 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/ */

    

sikker / phinatra example snippets




ikker\Phinatra\Request;
use Sikker\Phinatra\Response;
use Sikker\Phinatra\Router\Router;
use Sikker\Phinatra\Router\RouterException;
use Sikker\Phinatra\Router\Route;
use Sikker\Phinatra\Router\Path;

$path = new Path();
$router = new Router($path);

$router->attach(new Route('/menu/for/tonight', function(Request $request, Response $response){
	$response->setOutput('Spam, egg, sausage and spam');
	return $response;
}));

try {
	$response = $router->route(new Request($path), new Response());
} catch (RouterException $e) {
	$response = new Response();
	$response->setStatusCode(404);
	$response->setOutput( $e->getMessage() );
}

$response->handle();