PHP code example of afief / slim

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

    

afief / slim example snippets




= new Slim\App();

$app->get('/hello/{name}', function ($request, $response, $args) {
    $response->write("Hello, " . $args['name']);
    return $response;
});

$app->run();

$mw = function ($request, $response, $next, $arg1, $arg2) {
    $response->getBody()->write($arg1);
    $response = $next($request, $response);
    $response->getBody()->write($arg2);

    return $response;
};

$app->get('/hello/{name}', function ($request, $response, $args) {
    $response->write("Hello, " . $args['name']);
    return $response;
})->add($mw, ['first_argument', 'second_argument']);