Download the PHP package yazanstash/csv without Composer
On this page you can find all versions of the php package yazanstash/csv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yazanstash/csv
More information about yazanstash/csv
Files in yazanstash/csv
Package csv
Short Description A nice API to write csv files.
License MIT
Homepage https://github.com/yazan-stash/csv
Informations about the package csv
A nice API to write CSV files.
This is just a very light weight package to write to a csv file, it's basically a wrapper around fputcsv
.
It also handles the file's creation, opening and closing.
Installation
You can install the package via composer:
Usage
You can choose between providing a file path and name to the create()
method or letting it generate one, by default the generated file is located at /tmp/{random-file-name}.csv
.
Caution: If the file already exists, the package will overwrite it.
Customizing the write parameters
To customize the parameters of writing, you have 3 dynamic methods available at your disposal, delimiter()
, enclosure()
and escapeCharacter()
. Passing an argument will change the value, and calling the method without it will give you the current value of it. In the case of overwriting the value, it will give you back the object for those sick chains ;)
Writing to file
Use the write()
method to write new lines to the file, the method expects an array of values to be written.
each call to write()
will create a new line.
Getting the file path back
To get the written file path back, just call filePath()
on the instance.
Manually closing the file
If you need to close the file manually for some reason (the package automatically does that upon destructing the instance), you can call closeFile()
on the instance.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
- Yazan Stash
- All Contributors
License
The MIT License (MIT). Please see License File for more information.