Download the PHP package artkoder/kvpparser without Composer

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

KVP Parser

A library to read and parse files with key value pairs.

What is a KVP file

A KVP file consists of records of key value pairs separated by empty lines.

Here is an example:

Here is a differnt example with a comment. Lines starting with # are comments ignored by the parser.

I started using this type of file in different projects because it's similar to yaml but without the nesting and it's parsing complexity. So I decided to build a library to make the code reusable.

Installation

Using composer

How to use this library

Here are some examples:

Parse a single file

Supose we have the following file named budget.kvp:

We can parse the file and receive an associative array by running the following code:

Here is the output:

Parse multiple files inside a directory recursively

You can specify a directory. KvpParser will parse all the files found in that directory and subdirectories.

By default KvpParser will look for files with extension .kvp. But you can specify any file extensions. For example:

Convert a CSV file to a KVP file

This is very convenient. Suppose that you have a csv file with the following data from your bank statement:

Let's say that we are only interested in the following data: Date, Description 1 and CAD$. But we also want to change the column names in our resultin .kdp file.

Here is what we can do:

Here are the contents of transactions.kdp:

If no $columnMap is specified, the column names in the csv file will become the name of the properties in the kvp file.

Some times you need to do some processing of data during mapping, we can do that adding closures to the map array.

In our previous example, suppose you want ot combine both description columns and format date to be Y-m-d.

Here is how you would do it:

Notice also that the column uncategorized does not exist. In this case the word uncategorized would be use as the value.


All versions of kvpparser with dependencies

PHP Build Version
Package Version
No informations.
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 artkoder/kvpparser contains the following files

Loading the files please wait ....