PHP code example of jadephp / jade

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

    

jadephp / jade example snippets



use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Zend\Diactoros\Response;

// 1. Create App
$app = new Jade\App();

// 2. Add routes
$app->get('/ping', function(ServerRequestInterface $request){
    return new Response\TextResponse('pong');
});

// 3. Add middlewares
$app->pipe(function(ServerRequestInterface $request, RequestHandlerInterface $handler){
   $response = $handler->handle($request);
   return $response->withHeader('X-Jade-Version', '0.0.1');
});

// 4. Listen and serve.
$app->serve();
bash
php -S 127.0.0.1:8000