2017 © Pedro Peláez
 

library file-utils

File utilities.

image

ironedge/file-utils

File utilities.

  • Monday, December 28, 2015
  • by comfortablynumb
  • Repository
  • 1 Watchers
  • 0 Stars
  • 97 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

File Utils

Build Status Dependency Status Reference Status, (*1)

Description

This component allows you to load, save, encode and decode files of different types on a very simple way., (*2)

Currently supported formats:, (*3)

  • JSON
  • YAML

See the roadmap to know which other file types will be supported in future versions., (*4)

Usage

To open a file, use the following code:, (*5)

``` php, (*6)

use IronEdge\Component\FileUtils\File\Factory;, (*7)

$factory = new Factory();, (*8)

// $file will be an instance of a subclass of \IronEdge\Component\FileUtils\File\Base . // It detects the file type by its extension, and creates an instance of the appropiate // class, if it's available., (*9)

$file = $factory->createInstance('/path/to/your/file');, (*10)

// File contents are lazy loaded and decoded. When you call the "getContents" method, it opens // the file and decodes its data., (*11)

$data = $file->getContents();, (*12)

// Suppose we've open a JSON file with contents {"myParam": "myValue"}, (*13)

print_r($data);, (*14)

// It would print, (*15)

Array ( [myParam] => myValue ), (*16)

// If you need to update the file, (*17)

$data['myParam'] = 'newValue !';, (*18)

$file->setContents($data);, (*19)

$file->save();, (*20)

```, (*21)

Roadmap

  • XML Handling.

The Versions

28/12 2015

dev-master

9999999-dev http://www.ironedgesoftware.com

File utilities.

  Sources   Download

MIT

The Requires

  • php ^5.6.0 || ^7.0

 

The Development Requires

file json xml