Download the PHP package simplicity-ag/cao-csv-output without Composer
On this page you can find all versions of the php package simplicity-ag/cao-csv-output. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download simplicity-ag/cao-csv-output
More information about simplicity-ag/cao-csv-output
Files in simplicity-ag/cao-csv-output
Package cao-csv-output
Short Description Zend Framework 2 Module for generating CSV output from an array.
License
Homepage https://github.com/chrisoconnell/CaoCsvOutput
Informations about the package cao-csv-output
CaoCsvOutput
Zend Framework 2 Module for generating CSV output from an array.
This module provides both a Model and View Helper with which you can use to output
the csv data. When using the view helper, the output will automatically be passed
throught the escapeHtml view helper and all new lines will be converted to <br>
.
Installation
Main Setup
By cloning project
- Install the CaoCsvOutput ZF2 module
by cloning it into
./vendor/
. - Clone this project into your
./vendor/
directory.
With composer
-
Add this project in your composer.json:
- Now tell composer to download CaoCsvOutput by running the command:
Post installation
- Enabling it in your
application.config.php
file.
Usage
You can either create an instance of CaoCsvOutput\Model\Csv
or use the view helper
csvOutput
.
Example of Instance
- Define the data as an array.
- Create a new instance of
CaoCsvOutput\Model\Csv
using$data
as the input. -
Output the result using the
render
method. - Which will set
$output
to be
View Helper Example
- Define the data like before.
- From within your view script (.phtml file) simply call the view helper.
Input Parameters
You can easily change the characters used for the CSV output by setting the attributes parameters when calling either the View Helper or the Model class.
- Data
- (array) Input array which gets converted to CSV output
- Delimiter
- (string) Character separating the fields of the CSV output. Default is
;
- Enclosure
- (string) Character that surounds the field text. Default is
"
- Enclose All
- (bool) If every field should be enclosed by the Enclosure string or not.
Defalut isfalse
. By default, only fields which contain a space, the delimiter, or the enclosure will be enclosed by the enclosure character.
Example
If using the input from above, the output would be