PHP code example of robertkleinschuster / zenith

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

    

robertkleinschuster / zenith example snippets


    

    use Mosaic\Fragment;
    use Psr\Http\Message\ServerRequestInterface;

    return function(ServerRequestInterface $request, array $params) {
        $userId = $params['userId'];
        $content = "<h1>User Profile for User ID: {$userId}</h1>";

        return new Fragment($content);
    };
    

    

    use Mosaic\Fragment;
    use Mosaic\Renderer;

    return function(Renderer $renderer, $children) {
        $html = "<html><body>{$renderer->render($children)}</body></html>";

        return new Fragment($html);
    };
    

    

    use Psr\Http\Message\ResponseInterface;
    use Psr\Http\Message\ServerRequestInterface;

    return function(ServerRequestInterface $request, ResponseInterface $response) {
        $formData = $request->getParsedBody();
        $response->getBody()->write("Form data: " + htmlspecialchars($formData['data']));

        return $response;
    };