1. Go to this page and download the library: Download rapp-lib/middleman 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/ */
rapp-lib / middleman example snippets
use Psr\Http\Message\RequestInterface as Request;
use Zend\Diactoros\Response;
$dispatcher = new Dispatcher([
function (Request $request, callable $next) {
return $next($request); // delegate control to next middleware
},
function (Request $request) {
return (new Response())->withBody(...); // abort middleware stack and return the response
},
// ...
]);
$response = $dispatcher->dispatch($request);
use Psr\Http\Message\RequestInterface as Request;
class MyMiddleware implements MiddlewareInteface
{
public function __invoke(Request $request, callable $next) {
// ...
}
}
$dispatcher = new Dispatcher(
[
RouterMiddleware::class,
ErrorMiddleware::class,
],
new ContainerResolver($container)
);
use Zend\Diactoros\Response;
function ($request, $next) {
return (new Response())->withBody(...); // next middleware won't be run
}
function ($request, $next) {
if ($request->getMethod() !== 'POST') {
return $next($request); // run the next middleware
} else {
// ...
}
}
function ($request, $next) {
$result = $next($request); // run the next middleware
return $result->withHeader(...); // then modify it's response
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.