1. Go to this page and download the library: Download oasis/http 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/ */
oasis / http example snippets
use Oasis\Mlib\Http\MicroKernel;
use Symfony\Component\HttpFoundation\Response;
$config = [
'routing' => [
'path' => 'routes.yml',
'namespaces' => ['App\\Controllers\\'],
],
];
$isDebug = true;
$kernel = new MicroKernel($config, $isDebug);
$kernel->run();
use Oasis\Mlib\Http\MicroKernel;
use Symfony\Component\Routing\Route;
$kernel = new MicroKernel($config, $isDebug);
// inject a single route
$kernel->addRoute('health_check', new Route('/health', [
'_controller' => 'HealthController::check',
]));
// inject a collection of routes
$routes = new \Symfony\Component\Routing\RouteCollection();
$routes->add('api.users', new Route('/api/users', [
'_controller' => 'UserController::list',
]));
$kernel->addRoutes($routes);
$kernel->run();
use Symfony\Component\HttpFoundation\JsonResponse;
class MyViewHandler
{
function __invoke($rawResult, Symfony\Component\HttpFoundation\Request $request)
{
return new JsonResponse($rawResult);
}
}