emptygif
ભાષા: ગુજરાતી

બધી ભાષાઓ અને ફ્રેમવર્ક

Symfony PHP

Symfony માટે PHP સ્નિપેટ, જે /pixel.gif પરની રિક્વેસ્ટનો જવાબ empty GIF થી આપે છે. GIF સ્ટાર્ટઅપ વખતે એક જ વાર ડિકોડ થાય છે.

Symfony PHP

ઇન્સ્ટૉલ
composer create-project symfony/skeleton app
ફાઇલ
PixelController.php
ચલાવો
symfony server:start --port=8080
<?php

// src/Controller/PixelController.php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

final class PixelController
{
    private const GIF_BASE64 = 'R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';

    #[Route('/pixel.gif', name: 'pixel', methods: ['GET'])]
    public function __invoke(): Response
    {
        $gif = base64_decode(self::GIF_BASE64);

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

અમે આ સ્નિપેટ ચલાવ્યો અને તેણે પરત કરેલા બાઇટની સરખામણી કરી.

ચકાસો

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

સત્તાવાર સાઇટ: Symfony

PHP માં વધુ