PHPackages                             getsky/royal-stag - 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. getsky/royal-stag

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

getsky/royal-stag
=================

PEG for PHP

24.4k↓66.7%2[1 issues](https://github.com/JimmDiGrizli/RoyalStag/issues)PHPCI failing

Since Oct 27Pushed 4y ago2 watchersCompare

[ Source](https://github.com/JimmDiGrizli/RoyalStag)[ Packagist](https://packagist.org/packages/getsky/royal-stag)[ RSS](/packages/getsky-royal-stag/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

RoyalStag
=========

[](#royalstag)

[![Build Status](https://camo.githubusercontent.com/99db2c3b8220bcbf4e2043fdbd107418b7c39823babacf46475a1dc7f2a41a29/68747470733a2f2f7472617669732d63692e6f72672f4a696d6d44694772697a6c692f526f79616c537461672e737667)](https://travis-ci.org/JimmDiGrizli/RoyalStag)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5c7803731a1ffc7820382a7f31b320960ab3a00bb58481b1bbeb8a7487aef004/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a696d6d44694772697a6c692f526f79616c537461672f6261646765732f7175616c6974792d73636f72652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/JimmDiGrizli/RoyalStag/?branch=develop)[![Code Coverage](https://camo.githubusercontent.com/b2790ff0bafe517bad690dbcccab372a229e52ca3d1d45dabe4b415c95d47c2a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a696d6d44694772697a6c692f526f79616c537461672f6261646765732f636f7665726167652e706e673f623d646576656c6f70)](https://scrutinizer-ci.com/g/JimmDiGrizli/RoyalStag/?branch=develop)

RoyalStag is a PHP library for parsing text realizes the strengths of parsing expression grammar, or [PEG](http://en.wikipedia.org/wiki/Parsing_expression_grammar "Parsing expression grammar"). The main feature is the grammar, which is set directly in the code of PHP. This means that you do not need to learn any third-party formats to start using the library, and you do not lose the opportunities that gives you your favorite IDE (syntax highlighting, refactoring, etc.).

#### Easy integration into your projects

[](#easy-integration-into-your-projects)

To integrate the library into your project, you will not have to spend a lot of time and effort. The open and flexible architecture easily integrates into any architectural solution, as there is no need for third-party tools to generate a parser. The only thing you have to do is add one line composer.json:

```
"getsky/royal-stag": "0.9.1@dev"

```

#### Why not regular expressions?

[](#why-not-regular-expressions)

In many cases, it also lacks the ability to parse the text, such as embedded designs that require a recursive definition of the rules. They also do not provide appropriate error messages, and it can save a lot of time both during development and in support of software. And of course the ease of learning.

#### Why not ANTLR and other enterprise?

[](#why-not-antlr-and-other-enterprise)

ANTLR and others like it may all libraries that can RoyalStag and even more, but not always appropriate to use such a large library, which require much more time to study, develop with them and their continued support of software products.

Simple example
--------------

[](#simple-example)

The following example shows operating principle:

```
