diegogonda / stream-converter
There is no license information available for the latest version (dev-master) of this package.
Librería que nos permite leer y escribir ficheros en distintos formatos para gestionar su información
dev-master
2019-04-28 12:00 UTC
Requires
- php: ^7.0
This package is auto-updated.
Last update: 2025-04-29 01:00:59 UTC
README
Esta librería nos permite realizar la gestiona los contenidos de ficheros en distintos formatos.
Instalar
composer require diegogonda/stream-converter
Cómo se usa
Lectura
Veamos un ejemplo en CSV:
include 'vendor/autoload.php'; use handler\CSV as CSVHandler; $csvHandler = new CSVHandler(); $usuario = $csvHandler->read("./files/csv/usuario.csv"); var_dump($usuario);
Escribir
Veamos un ejemplos en JSON:
include 'vendor/autoload.php'; use handler\JSON as JSONHandler; $data = [ 'dato1' => 1, 'dato2' => 2, 'dato3' => '3' ]; $jsonHandler = new JSONHandler(); $usuario = $jsonHandler->write("./files/json/data.json", $data);
Lectura/escritura de un fichero, transformando el formato
include 'vendor/autoload.php'; use handler\CSV as CSVHandler; use handler\JSON as JSONHandler; use converter\Manager; $manager = new Manager(); $manager->convert( new CSVConverter(), new JSONHandler(), "./files/csv/ejemplo.csv", "./files/json/usuario.json" );