emptygif
Language: English

All languages and frameworks

Tempest PHP

A PHP snippet for Tempest that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

Tempest PHP

Install
composer create-project tempest/app my-app
File
PixelController.php
Run
php tempest serve
<?php
// app/PixelController.php: Tempest discovers the #[Get] route, no registration needed.

namespace App;

use Tempest\Http\Response;
use Tempest\Http\Responses\Ok;
use Tempest\Router\Get;

final readonly class PixelController
{
    #[Get('/pixel.gif')]
    public function __invoke(): Response
    {
        return new Ok(base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='))
            ->addHeader('Content-Type', 'image/gif')
            ->addHeader('Cache-Control', 'no-store');
    }
}

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: Tempest

More in PHP