Download the PHP package misatotremor/csv-bundle without Composer
On this page you can find all versions of the php package misatotremor/csv-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download misatotremor/csv-bundle
More information about misatotremor/csv-bundle
Files in misatotremor/csv-bundle
Package csv-bundle
Short Description Symfony2 CSV Bundle
License MIT
Homepage http://github.com/MisatoTremor/AvroCsvBundle
Informations about the package csv-bundle
AvroCsvBundle
This bundle provides an easy way to upload data to your db using csv files with just a few configuration parameters.
This is a fork of jdewits original code.
Status
This bundle is under development and may break.
Limitations
This bundle uses php and Doctrine and is not your best bet for importing gargantuan csv files. Use your databases native importing & exporting solutions to skin that cat.
Features
- Import data by csv file
- Export data to csv file
- A few services for reading/writing csv files
Supports
- Doctrine ORM
Installation
This bundle is listed on packagist.
Download the bundle
Enable the bundle as well as the dependent AvroCaseBundle:
Configuration
Add this required config
Add routes to your config
Add the entities/documents you want to implement importing/exporting for
To exclude certain fields from being mapped, use the ImportExclude annotation like so.
Since PHP 8 you can also use it as an attribute like this
Importing
Implement importing for as many entities/documents as you like. All you have to do is add them to the objects node as mentioned previously.
Then just include a link to specific import page like so:
Replace "client" with whatever alias you called your entity/document in the config.
Views
The bundle comes with some basic twitter bootstrap views that you can override by extending the bundle.
Association mapping
An event is fired when importing an association field to allow implementing your own logic fitting
Just create a custom listener in your app that listens for the AssociationFieldEvent::class
event.
A simple implementation getting an associated entity by name could look like:
Customizing each row
Want to customize certain fields on each row? No problem.
An event is fired when a row is added that you can tap into to customize each row of data.
Just create a custom listener in your app that listens for the RowAddedEvent::class
event.
For example...
Register your listener or use autowiring
Exporting
This bundle provides some simple exporting functionality.
Navigating to "/export/your-alias" will export all of your data to a csv and allow you to download it from the browser.
You can customize the export query builder and the exported data by listening to the
corresponding events (See events in the Avro\CsvBundle\Event
namespace).
If you want to customize data returned, just create your own controller action and grab the queryBuilder from the exporter and add your constraints before calling "getContent()".
Ex.
Register your controller or use your already setup autowiring
To Do:
- Finish mongodb support
Acknowledgements
Thanks to jwage's EasyCSV for some ground work.
Feedback and pull requests are much appreciated!