Download the PHP package mehr-it/csv without Composer

On this page you can find all versions of the php package mehr-it/csv. 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 csv

Advanced CSV reader and writer for PHP

This library aims to offer advanced support for CSV in PHP. This includes charset conversions, proper handling of escape sequences and byte order marks (for UTF-8, UTF-16 and UTF-32).

The CSV writer also supports "always quoting" and custom line-breaks (EOL).

Writer usage

Following example is quite self-explaining:

$writer = new CsvWriter();
$writer
    ->setDelimiter(';')
    ->setEnclosure("'")
    ->setEscape('\\')
    ->setAlwaysQuote(true)
    ->open($resource)
    ->writeLine(['a', 'b', 'c'])
    ->close();

You may also pass your data as associative array with column keys if you define columns first. This allows to omit empty columns:

$writer = new CsvWriter();
$writer
    ->open($resource)
    ->columns(['a' => 'Col A', 'b' => 'Col B', 'c' => 'Col C'])
    ->writeData(['a' => 15, 'b' => 16, 'c' => 17])
    ->writeData(['a' => 15, 'b' => 16])
    ->close();

Reader usage

$reader = new CsvReader();
$reader
    ->setDelimiter(';')
    ->setEnclosure("'")
    ->setEscape('\\')
    ->open($resource);

while (($line = $reader->readLine()) !== false) {
    var_dump($line);
}

$reader->close();    

To receive associative arrays with column keys, columns can be read from first line and use the readData() method:

$reader = new CsvReader();
$row = $reader
    ->open($resource)
    ->readColumns()
    ->readData();

If columns are not present in file, they can be set manually:

$reader = new CsvReader();
$row = $reader
    ->open($resource)
    ->setColumns(['a', 'b'])
    ->readData();

Casting values

Following example demonstrates the usage of casts, for easy reading data types:

 $reader = new CsvReader();
 $row = $reader
     ->open($resource)
     ->setColumns(['a', 'b', 'c', 'd', 'e'])
     ->setCasts(
        'a' => 'number',
        'b' => 'json',
        'c' => 'split:|'
        'd' => function($v) {
            return 'x-' . $v;
        },
        'e' => 'number:,:.',
     );
     ->readData();

If a value cannot be casted, null will be returned for the field.


All versions of csv with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
ext-mbstring Version *
ext-iconv Version *
thecodingmachine/safe Version ^1.3.3
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 mehr-it/csv contains the following files

Loading the files please wait ....