PHP code example of stack / url-map
1. Go to this page and download the library: Download stack/url-map 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/ */
stack / url-map example snippets
use Symfony\Component\HttpFoundation\Request;
use Silex\Application;
$app = new Application();
$app->get('/', function () {
return "Main Application!";
});
$blog = new Application();
$blog->get('/', function () {
return "This is the blog!";
});
$map = [
"/blog" => $blog
];
$app = (new Stack\Builder())
->push('Stack\UrlMap', $map)
->resolve($app);
$request = Request::createFromGlobals();
$response = $app->handle($request);
$response->send();
$app->terminate($request, $response);