emptygif
Idioma: Español

Todos los lenguajes y frameworks

CodeIgniter 4 PHP

Un fragmento en PHP para CodeIgniter 4 que responde a las peticiones a /pixel.gif con el GIF vacío, decodificado una sola vez al arrancar.

CodeIgniter 4 PHP

Instalar
composer create-project codeigniter4/appstarter my-app
Archivo
Routes.php
Ejecutar
php spark serve
<?php
// app/Config/Routes.php

use CodeIgniter\Router\RouteCollection;

/** @var RouteCollection $routes */
$routes->get('/', 'Home::index');

$routes->get('/pixel.gif', static fn () => service('response')
    ->setContentType('image/gif', '')
    ->setHeader('Cache-Control', 'no-store')
    ->setBody(base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==')));

Ejecutamos este fragmento y comparamos los bytes que devolvió.

Comprobar

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

Sitio oficial: CodeIgniter 4

Más en PHP