1. Go to this page and download the library: Download desilva/microserve 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/ */
desilva / microserve example snippets
$app = \Desilva\Microserve\Microserve::boot(\App\Http\MyHttpKernel::class);
$app->handle(); // Process the request to create and send the response
class HttpKernel implements HttpKernelInterface
{
public function handle(Request $request): Response
{
return Response::make(200, 'OK', [
'body' => 'Hello World!',
]);
}
}
public function send(): static
{
// Your implementation
return $this;
}
// In your HttpKernel or similar class
public function handle(Request $request): Response
{
return Response::make(200, 'OK', ['body' => 'Hello World!']);
// OR: return new Response(200, 'OK', ['body' => 'Hello World!']);
}
// In your application entry point
$app = new Application(new MyHttpKernel());
$app->handle(); // This will now send the response
use Desilva\Microserve\HtmlResponse;
// In your HttpKernel or similar class
public function handle(Request $request): Response
{
return new HtmlResponse(200, 'OK', ['body' => '<html><body>Hello World!</body></html>']);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.