Download the PHP package offdev/csv without Composer

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

Offdev/Csv

Latest Stable Version Minimum PHP Version Build Status PHPStan Mutation Score License

Requirements

Installation

Introduction

This parser has been written, in order to parser big CSV files from almost any data source in an easy and convenient way. It also provides the possibility to validate each record from the CSV source.

In order for the parser to work, you need to feed it with data. This data will be represented as a stream. This allows us to handle huge amounts of data. The parser can also work with HTTP streams.

Please read further to see how it is used.

Streams

In order to feed the parser with data, you need to give it a stream. A stream can be obtained in a different number of ways:

Using resources

Using strings

Note: this method also works for any object which implements the method.

Using HTTP streams (see PSR-7/Streams)

Convenience

If you want to quickly create a stream, you can use the provided helper function. You need to use composer's autoloader to be able to use this.

Parser

Basics

Once the parser has a stream to work with, we can start using it:

The example above produces following output:

For convenience, the parser can also be used as an iterator:

This will produce the same output as the example above.

Options

The parser accepts a number of options. The parser accepts options in an array, which is passed a a second argument to the constructor:

Full list of options:

Option Value Type Default Value Description
\ Defines the size of the buffer which is used when reading streams.
\ Tells the parser if the CSV contains a header. This header will be used as keys for the records read from the stream.
\ Defines the delimiter used in the CSV file to mark columns.
\ Defines the delimiter used for strings.
\ Defines the character used to escape other control characters.
\ Defines the line ending used in the CSV file. Unix files mostly use while windows mostly uses .
\ Tells the parser to throw an exception when an invalid records was found in the stream.

Processor

For better usability and separation of concerns, the parser accepts a processor, which will receive any parsed records from the stream. Records are represented as Laravel collections.

If a validator was assigned to the parser, valid and invalid records will be passed to the respective methods. If no validator was given, all records will be passed to the method. Empty lines will always be ignored.

Example processor:

Usage:

The example above produces following output:

Validator

Now, most of the times, we want to make sure the data contained in the CSV is in a given format. This package uses the Laravel validation package in order to provide a rule engine for the content of the CSV. A full list of all rules can be found here.

Usage:

Code quality

First, make sure to install the dependencies by running . You also need to make sure to have xdebug activated in order for PHPUnit to generate the code coverage.

PHP Code Sniffer

PHPUnit

Infection

License

Apache-2.0


All versions of csv with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
psr/http-message Version ^1.0
illuminate/support Version ^5.6
illuminate/validation Version ^5.6
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 offdev/csv contains the following files

Loading the files please wait ....