Download the PHP package chrismou/php-eol-csv without Composer
On this page you can find all versions of the php package chrismou/php-eol-csv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chrismou/php-eol-csv
More information about chrismou/php-eol-csv
Files in chrismou/php-eol-csv
Package php-eol-csv
Short Description A class for creating CSV files, allowing you to set a custom end-of-line character
License MIT
Homepage http://github.com/chrismou/php-eol-csv
Informations about the package php-eol-csv
Archived
When I wrote this it did exactly what I needed it to do, but with the number of great 3rd party packages available now it's not really needed anymore. If you want full control of your CSVs, check out the excellent phpleague/csv
PHP Custom end-of-line CSV class
About
This class provides the flexibility of creating CSV files in PHP with a custom end-of-line character.
PHP's fputcsv
function allows you to specify a field delimiter, but strangely doesn't let you set the EOL character - which, when it insists on \n
,
isn't always helpful when the files are destined for people to view/edit on a Windows based systems.
Install
To install via Composer:
Usage
Instantiate the class:
Open a CSV file for editing:
- $fileName (required) - the filename to use. Don't include the file extension, this can be set seperately.
- $savePath - The path to save the file. Leaving this blank will save directly to the output buffer for a direct download.
- $eol - The EOL character/string to use. Defaults to
\n
. - $fileExtension - The file extension to use. Defaults to
csv
. - $delimiter - The character/string to use as a separator between fields. Defaults to
,
. - enclosure - The character to use to enclose multi-word strings, or strings that include the delimiter character. Defaults to
"
.
Write a row to the CSV:
Finish editing and close the file:
Supported versions
PHP 5.3 upwards, including HHVM.
Tests
To run the unit test suite:
A DUnit config file is also included, allowing you to easily run tests on all supported PHP versions.
First, you need to have docker installed. This is fairly simple on Linux - on OSX and Windows, take a look at docker machine.
Assuming you have composer setup (see above), run the tests with the following command:
License
Released under the MIT License. See LICENSE.md.