PHPackages                             tarsana/syntax - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tarsana/syntax

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tarsana/syntax
==============

A tool to encode and decode strings based on flexible and composable syntax definitions.

2.1.0(8y ago)41.2k11MITPHPPHP ^7.0

Since Jun 25Pushed 7mo ago3 watchersCompare

[ Source](https://github.com/tarsana/syntax)[ Packagist](https://packagist.org/packages/tarsana/syntax)[ RSS](/packages/tarsana-syntax/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (8)Dependencies (1)Versions (11)Used By (1)

Tarsana Syntax
==============

[](#tarsana-syntax)

[![Build Status](https://camo.githubusercontent.com/f6628a83d03a2f17685e43de352b68ead0b846c2e6b0c0016e96742becdebf7f/68747470733a2f2f7472617669732d63692e6f72672f74617273616e612f73796e7461782e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/tarsana/syntax)[![Coverage Status](https://camo.githubusercontent.com/0ad93376916f563c7314edf394e7a2b9d90bd0a9a07e4d039d9e56852e633357/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f74617273616e612f73796e7461782f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/tarsana/syntax?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/a4701721e2ea52502e5d1ce7ddde48bfe729c440440582338ae1d4bdc71d9a00/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f38643337306566392d646631622d343363332d383037332d3962313738373036353965622f6d696e692e706e67)](https://insight.sensiolabs.com/projects/8d370ef9-df1b-43c3-8073-9b17870659eb)[![Software License](https://camo.githubusercontent.com/f251623e510f5909f16ae3f4e6e548dac11340b9fde1a99be26b015b39272c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/tarsana/syntax/blob/master/LICENSE)

A tool to encode and decode strings based on flexible and composable syntax definitions.

Table of Contents
=================

[](#table-of-contents)

- [Quick Example](#quick-example)
- [Installation](#installation)
- [Step by Step Guide](#step-by-step-guide)

    - [Parsing and Dumping Strings](#parsing-and-dumping-strings)
    - [Parsing and Dumping Numbers](#parsing-and-dumping-numbers)
    - [Parsing and Dumping Booleans](#parsing-and-dumping-booleans)
    - [Parsing and Dumping Arrays](#parsing-and-dumping-arrays)
    - [Parsing and Dumping Optional Syntaxes](#parsing-and-dumping-optional-syntaxes) **Since version 2.0**
    - [Parsing and Dumping Objects](#parsing-and-dumping-objects)
    - [Parsing and Dumping Syntaxes](#parsing-and-dumping-syntaxes) **Since version 1.2.0**
- [Development Notes &amp; Next Steps](#development-notes--next-steps)
- [Contributing](#contributing)

Quick Example
=============

[](#quick-example)

**Warning**: This is just a teaser so if the code seems confusing don't worry, you will understand it after reading the [Step by Step Guide](#step-by-step-guide).

Let's assume that you have the following text representing a list of developers where each line follow the syntax:

```
first-name last-name [number-of-followers] [repo-name:stars,repo-name:stars,...]

```

```
Tammy Flores  257 library:98,fast-remote:5,anyway:987
Rebecca Welch forever:76,oops:0
Walter Phillips 423

```

**Syntax** helps you to parse this document and convert it to manipulable objects easily.

Let's do it:

```
