PHP code example of z7zmey / slim-found-handler

1. Go to this page and download the library: Download z7zmey/slim-found-handler 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/ */

    

z7zmey / slim-found-handler example snippets


$app = new \Slim\App([
    'foundHandler' => function () {
        return new \z7zmey\SlimFoundHandler();
    }
]);

$app->get('/', function (\Slim\Http\Response $response) {
    $response->getBody()->write("Hello");
    return $response;
});

$app->get('/example1/{name}', function ($name) {
    echo "Hello, {$name}";
});

$app->get('/example2/{first}/{second}', function (array $routeArguments) {
    echo "{$routeArguments['first']} {$routeArguments['second']}";
});

use \Slim\Http\Response;
use \Slim\Http\Request;

$routeHandler = function ($first, Response $res, array $params, Request $req) {
    $second = $params['second'];
    $third = $req->getAttribute('route')->getArgument('third');

    $res->getBody()->write("{$first} {$second} {$third}");
    return $res;
};

$app->get('/example3/{first}/{second}/{third}', $routeHandler);