Skip to content
/ csv Public
forked from mnshankar/csv

Simple CSV generation and consumption for Laravel4

Notifications You must be signed in to change notification settings

damiani/csv

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy CSV file manipulation (Read, Write and Download)

This is a simple utility package that helps you work with CSV files using a succint and readable syntax popularised by Laravel 4.

##Installation with Composer

Add this line to your composer.json file in the `require field:

"mnshankar/CSV": "dev-master"

Then open app/config/app.php and add the following line in the providers array:

'providers' => array(
    'mnshankar\CSV\CSVServiceProvider',
)

and the following in the 'alias' array

'alias' => array(
    'CSV'             =>'mnshankar\CSV\CSVFacade',
)

Now, in your application you can work with CSV files like so:

$arr = User::all()->toArray();	//use eloquent to get array of all users in 'users' table

return CSV::with($arr)->put(storage_path().'/downloads/myusers.csv');	//store as csv in this path
return CSV::fromArray($arr)->render();	//download as csv
return CSV::fromFile(storage_path().'/downloads/my.csv')->render('abc.csv'); //render saved csv file as a downloadable document
return CSV::with(storage_path().'/downloads/my.csv')->render('abc.csv'); //use 'with'.. same as previous

Note that the 'with' statement can accept either an array or file path and work accordingly.

License

This is open-sourced software licensed under the MIT license

About

Simple CSV generation and consumption for Laravel4

Resources

Stars

Watchers

Forks

Packages

No packages published