dev-master
9999999-dev http://www.ironedgesoftware.comFile utilities.
MIT
The Requires
- php ^5.6.0 || ^7.0
The Development Requires
file json xml
File utilities.
This component allows you to load, save, encode and decode files of different types on a very simple way., (*2)
Currently supported formats:, (*3)
See the roadmap to know which other file types will be supported in future versions., (*4)
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)
File utilities.
MIT
file json xml