Skip to content

Instantly share code, notes, and snippets.

@pazteddy
Created February 19, 2026 15:37
Show Gist options
  • Select an option

  • Save pazteddy/ef6ddd08a49b995a75ca72bf9ef22c25 to your computer and use it in GitHub Desktop.

Select an option

Save pazteddy/ef6ddd08a49b995a75ca72bf9ef22c25 to your computer and use it in GitHub Desktop.
Código base para cargar productos y mensaje de error
<?php
function storagePath(): string
{
return __DIR__ . "/storage_products.json";
}
function loadProducts(): array
{
$path = storagePath();
$seed = [
["id" => 1, "name" => "Laptop", "price" => 1200.00, "stock" => 3],
["id" => 2, "name" => "Mouse", "price" => 25.00, "stock" => 15],
];
$dir = dirname($path);
if (!is_writable($dir)) {
respondError(500, "No se puede crear el archivo de almacenamiento.
La carpeta '$dir' no tiene permisos de escritura.
Asigna permisos de escritura a la carpeta para continuar.");
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment