Download the PHP package raphhh/balloon without Composer
On this page you can find all versions of the php package raphhh/balloon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download raphhh/balloon
More information about raphhh/balloon
Files in raphhh/balloon
Informations about the package balloon
Balloon - A tiny file data access layer (csv, json, xml, yaml)
Balloon is a file data access layer which supports different kinds of data formats.
It help you to get, add, modify or remove data (CRUD basic actions) from files like csv, json, xml or yaml.
You can work with objects or with arrays. With arrays, Balloon will extract the data of the file and gives you a list of array for every data. With objects, Balloon will map these data with objects of a specific class of your choice. Then, you can also work with specific collections of objects.
Finally, you can work with different file system abstractions (local, cloud,...). Balloon provides an adapter to use Gaufrette (but you can also add your own adapter).
Installation
Execute Composer:
Supported file formats
- json
- yaml
- xml (todo)
- csv (todo)
CRUD actions
Work with objects
With the object usage, Balloon will map data of your file into objects of a specific class.
Init
(Note that the pk is not mandatory. Id of object will be simple index.)
Get objects
Add object
Modify object
Remove object
Work with arrays
With the array usage, Balloon will map data of your file into arrays.
Init
Get data
Add data
Modify data
Remove data
Cache
The cache of Balloon prevents to access to the same file more than once when you try to read it.
You can invalidate the cache with the method "Balloon::invalidate()".
Unit of work
The unit of work of Balloon prevents to access to the same file more than once when you try to write it. So, that means you have to flush Balloon if you want to write into the file.
You can also rollback your modifications (only if you have not flushed!).
Object Mapping
Object
Balloon uses the JMS Serializer to serialize the objects.
This library can work with yaml, xml or annotations to map the data to their object.
For example, if you use annotations:
You can redefine the default Serializer in the second arg of the Balloon Factory:
For more information about JMS Serializer, see the documentation.
Collection
By default, if you work with a collection of data, Balloon returns an array of these data.
But if you work with objects for data, you can also work with specific collection class. You just have to declare a class with the same name as your data class, but in plural. This class will receive an array of the objects as first arg of the constructor.
For example, if you work with data object of the class 'Foo', you can declare a class 'Foos' as a collection.
Filesystem abstraction
By default, Balloon will read and write locally. But you can use other drivers, and work with other kind of filesystems.
The best way to proceed is to use a library such Gaufrette. Balloon provides an adapter for this library.
Extending Balloon
You can extend Balloon by creating a child:
But to instantiate easily this new class, you should also extend BalloonFactory and specify the name of your class:
Then you can use BeachBallFactory to create BeachBall in a same way than Balloon:
All versions of balloon with dependencies
icanboogie/inflector Version ~1.3
symfony/yaml Version ~3.0
jms/serializer Version ^1.0