Download the PHP package idct/php-csv-writer without Composer

On this page you can find all versions of the php package idct/php-csv-writer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-csv-writer

PHP CSV Writer

Basic CsvWriter based on a buffered TextWriter (also provided). Supports buffering in memory and proper handling of EOL setting which is not available easily with native fputcsv function.

Tests status Coverage Status GitHub tag (latest SemVer)

Main purpose of this library is to provide an object-oriented way of buffered CSV files writing.

Installation

The best way to install the library in your project is by using Composer:

of course you can still manually include all the required files in your project using using statements yet Composer and autoloading is more than suggested.

Usage

Create an instance:

Now you need to open or create a file, to do so you have two methods available: open and openWithFieldsNames To create a new file with without adding headers in the first line use:

To open a new file with fields' names added in the first line pass an array as the second argument:

When writing a new line (adding data) to a CSV file opened with fields names then columns count number is verified on each attempt.

It is possible to appened into existing files by passing __TextWriter::FILEMODE_APPEND__ as the last argument.

or:

Warning: in append mode lines are NOT added as the first line of the CSV file, they are used only for verification of columns count during write operations.

Buffering

By default CsvWriter has buffering disabled, you can enable it by providing buffer size (in bytes) using method setBufferSize. Be sure to understand that data is actually saved in the file only when buffer is filled so be sure to close the file using close method or use flush whenever you want to intentionally flush the buffer into the file without closing it.

EOL support

By default PHP's internal fputcsv function uses default EOL symbol for the current platform. idct/php-csv-writer supports setting different EOL symbols: pass CsvWriter::EOL_WINDOWS, CsvWriter::EOL_LINUX or CsvWriter::EOL_MACLEGACY (Mac today uses LINUX EOL, this is just for legacy support) to setEolSymbol method. Warning: the EOL symbol will be used only for NEXT lines, previous ones (already existing in the file or buffer) will remain intact.

TextWriter

CsvWriter is based on TextWriter which can be used for buffered text write operations. Apart from the methods described above it provides also different behavior for write and writeln operations which store the text or write it followed by the defined EOL symbol respectively. To use it just create an instance:

TODO / Contribution

At the moment the main requirement is to provide better unit tests and documentation, yet if you find any bugs or have potential feature ideas then please use Issues or Pull Requests, it is more than welcome! I will try to reply ASAP.


All versions of php-csv-writer with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ext-ctype Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package idct/php-csv-writer contains the following files

Loading the files please wait ....