emptygif
Wika: Filipino

Lahat ng language at framework

Tempest PHP

Isang PHP snippet para sa Tempest na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.

Tempest PHP

I-install
composer create-project tempest/app my-app
File
PixelController.php
Patakbuhin
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');
    }
}

Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.

Suriin

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

Opisyal na site: Tempest

Iba pa sa PHP