1. Go to this page and download the library: Download weew/http-app 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/ */
weew / http-app example snippets
$app = new HttpApp();
$app->getEventer()
->subscribe(HandleHttpRequestEvent::class, function(HandleHttpRequestEvent $event) {
$request = $event->getRequest();
// handle request (do some routing, call a controller, etc.)
// provide a response that implements the IHttpResponse interface
$event->setResponse($response);
});
$app->setDebug(true);
$request = new HttpRequest();
$request->getHeaders()->set('x-env', 'stage');
// or
$request->getUrl()->getQuery()->set('env', 'stage');
// or
$request->getUrl()->setPath('/env=stage/some/url');
// app will run in the "stage" environment
$app->handle($request);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.