1. Go to this page and download the library: Download phphleb/webrotor 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/ */
phphleb / webrotor example snippets
// Contents of your index.php file.
// Basic example for displaying the greeting line.
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Phphleb\Webrotor\WebRotor;
use Phphleb\Webrotor\Src\Handler\NyholmPsr7Creator;
->getBody()->write('Hello World!');
return $response;
});
// ... //
use Phphleb\Webrotor\Config;
$config = new Config();
$config->logLevel = 'warning'; // Logging level according to PSR-3.
$config->workerNum = 2; // Number of workers.
$config->workerLifetimeSec = 120; // Worker lifetime is two minutes.
$server = new WebRotor($config);
// ... //
// ... //
use Psr\Http\Message\ServerRequestInterface;
$server->run(function(ServerRequestInterface $request, ResponseInterface $response) {
// Example of assigning a session.
$request->getAttribute('session')->set('session_name', 'value');
// or
$_SESSION['session_name'] = 'value';
// An example of getting a value from a session.
$sessionParam = $request->getAttribute('session')->get('session_name');
// or
$sessionParam = $_SESSION['session_name'];
// An example of assigning and getting a Cookie value.
$request->getAttribute('cookie')->set('cookie_name', 'value', []);
$cookieParam = $request->getAttribute('cookie')->get('cookie_name');
// or
$cookieParam = $_COOKIE['cookie_name'];
$files = $request->getUploadedFiles(); // An array of special objects.
// or
$files = $request->getAttribute('files') // Standard array $_FILES
// or
$files = $_FILES;
return $response;
});
php index.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.