Download the PHP package nackjicholson/file-parser without Composer

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

file-parser

This is a composer package for parsing files that contain structured data.

The current supported formats are:

WARNING Only works with PHP 5.4 and up due to short array syntax and use of traits.

Example:

foobar.yml

example.php

Outputs:

Install

Via composer

compser require nackjicholson/file-parser=~2.1

or add too composer.json

CSV

This library provides three ways to parse a csv file into a php array. There is full support for delimiter, enclosure, and escape options by passing an associative array of options to each csv method. Options default to:

There is an example of how to set a file to parse with a ; delimiter in example/example.php.

::csv(mixed $file, array $options = [])

This method provides a literal parse of a file as a csv. Each line is translated to an array of values. Empty lines are not skipped.

$fileParser->csv('file.csv');

::csvColumnar(mixed $file, array $options = [])

Parses the contents of a csv as data structured columnar. Takes into account the first row of a csv file as column headers, and attaches each column header to its associated row value.

For example, a csv describing a table of contacts.

The first row is the headers of the table 'name', 'email', and 'phone'. The second row is a complete set of data. The third has a name, but empty email and phone. The fourth is not a row, it's a blank line.

$fileParser->csvColumnar('contacts.csv');

::csvRows(mixed $file, array $options = [])

Parses the contents of a csv where each row uses the first value as a key, which is set with the subsequent values. This is ideal for a csv which describes a set of key => value pairs, or key => [ values... ].

$fileParser->csvRows('rows.csv');

As you can see it ignores blank lines, or lines where the key would be empty.

INI

::ini(mixed $file)

This method will parse a php ini configuration file into an array. It delegates directly to PHP's built in function parse_ini_file.

$fileParse->ini('/etc/php55/php.ini');

JSON

::json(mixed $file)

Parses a json file into a php array. This parsing strategy delegates directly to PHP's built in json_decode.

$fileParser->json('foobar.json');

YAML

::yaml(mixed $file)

Parses a yaml file into a php array. This parsing strategy delegates directly to symfony/Yaml

$fileParser->yaml('foobar.yml');

SplFileInfo and SplFileObject Support

Instead of passing a path to any of the file-parser methods. You can supply either a SplFileInfo or SplFileObject object.

Contributing

Report issues, and feel free to make requests there. Tag github issues with the best label you can. If this library doesn't do something you want, it's not difficult to extend. The library is built on the strategy pattern, new strategies can parse data differently. Write tests, and make pull requests. If you do not test your code with 100% coverage, your PR will be rejected.

Contact me

Will Vaughn

email: [email protected]

twitter: @nackjicholsonn


All versions of file-parser with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
symfony/yaml Version ~2.5
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 nackjicholson/file-parser contains the following files

Loading the files please wait ....