ironedge / file-utils
File utilities.
Installs: 126
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/ironedge/file-utils
Requires
- php: ^5.6.0 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^4.5 || ^5.0.5
- phpunit/phpunit-mock-objects: 2.3.0 || ^3.0
Suggests
- justinrainbow/json-schema: Enabling JSON schema validation.
- seld/jsonlint: Enabling JSON lint validation.
- symfony/yaml: Enabling YAML files handling.
This package is not auto-updated.
Last update: 2025-09-27 22:59:49 UTC
README
Description
This component allows you to load, save, encode and decode files of different types on a very simple way.
Currently supported formats:
- JSON
- YAML
See the roadmap to know which other file types will be supported in future versions.
Usage
To open a file, use the following code:
use IronEdge\Component\FileUtils\File\Factory; $factory = new Factory(); // $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. $file = $factory->createInstance('/path/to/your/file'); // File contents are lazy loaded and decoded. When you call the "getContents" method, it opens // the file and decodes its data. $data = $file->getContents(); // Suppose we've open a JSON file with contents {"myParam": "myValue"} print_r($data); // It would print Array ( [myParam] => myValue ) // If you need to update the file $data['myParam'] = 'newValue !'; $file->setContents($data); $file->save();
Roadmap
- XML Handling.