PHP code example of paket / fram

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

    

paket / fram example snippets

 
    final class BufferedHtmlHandler implements ViewHandler
    {
        public function handle(Route $route, View $view): Route
        {
            ob_start();
            /** @var $view HtmlView */
            $newRoute = $view->render($route);
            if ($newRoute !== null && $newRoute !== $route) {
                ob_end_clean();
                return $newRoute;
            }
            ob_end_flush();
            return $route;
        }
    
        public function getViewInterface(): string
        {
            return HtmlView::class;
        }
    }  
    

    final class RequestHeaderRouter implements Router
    {
        /** @var Router */
        private $first;
        /** @var Router */
        private $second;
    
        public function __construct(Router $first, Router $second)
        {
            $this->first = $first;
            $this->second = $second;
        }
    
        public function route(string $method, string $uri): Route
        {
            if (/* check request header for condition to be true */) {
                return $this->first->route($method, $uri);
            }
            return $this->second->route($method, $uri);
        }
    }