emptygif
Lugha: Kiswahili

Lugha na framework zote

ReactPHP PHP

Kipande cha PHP kwa ReactPHP kinachojibu maombi ya /pixel.gif kwa empty GIF, ambayo husimbuliwa (decode) mara moja programu inapoanza.

ReactPHP PHP

Sakinisha
composer require react/http
Faili
server.php
Endesha
php server.php
<?php

use Psr\Http\Message\ServerRequestInterface;
use React\Http\HttpServer;
use React\Http\Message\Response;
use React\Socket\SocketServer;

require __DIR__ . '/vendor/autoload.php';

$gif = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');

$http = new HttpServer(function (ServerRequestInterface $request) use ($gif) {
    if ($request->getMethod() !== 'GET' || $request->getUri()->getPath() !== '/pixel.gif') {
        return new Response(Response::STATUS_NOT_FOUND);
    }

    return new Response(Response::STATUS_OK, [
        'Content-Type' => 'image/gif',
        'Cache-Control' => 'no-store',
    ], $gif);
});

$http->listen(new SocketServer('0.0.0.0:8080'));

Tuliendesha kipande hiki na kulinganisha baiti kilizorudisha.

Kagua

curl -sI http://localhost:8080/pixel.gif

Tovuti rasmi: ReactPHP

Zaidi katika PHP