PHPackages                             anexia/param-parser - 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. anexia/param-parser

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

anexia/param-parser
===================

Parses param placeholders within an arbitrary string

1.0.1(4y ago)111.7k—3.8%MITPHPPHP &gt;=7.1

Since Sep 10Pushed 3y ago2 watchersCompare

[ Source](https://github.com/anexia/php-param-parser)[ Packagist](https://packagist.org/packages/anexia/param-parser)[ Docs](https://github.com/anexia/php-param-parser)[ RSS](/packages/anexia-param-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

param-parser
============

[](#param-parser)

[![PHP version](https://camo.githubusercontent.com/83099f72e86f095b4240dbc16362334f4b52ba331d5eaa3aa156cf531a58274f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e657869612f706172616d2d7061727365722e737667)](https://packagist.org/packages/anexia/param-parser)[![Test status](https://github.com/anexia/php-param-parser/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/anexia/php-param-parser/actions/workflows/test.yml)[![Codecov](https://camo.githubusercontent.com/6db3ac092908e35b71a0831a332338cb55fe62537608c41b40894e46f65dd4cf/68747470733a2f2f636f6465636f762e696f2f67682f616e657869612f7068702d706172616d2d7061727365722f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/anexia/php-param-parser)

`param-parser` is a parser library for a param string expression. Those expressions are arbitrary strings with placeholders in it, where a placeholder consists of a name, an optional type and a list of options.

Install
=======

[](#install)

With a correctly set up PHP and composer installation, run:

```
composer require anexia/param-parser
```

Getting started
===============

[](#getting-started)

Examples of param string expressions look as follows:

```
this-is-a-{param:string:option1,option2,option3}-expression
this-is-a-{param:string}-expression
this-is-a-{param}-expression

```

As you see, a param is introduced by an opening curly bracket, followed by the name of the param, a colon, the type of the param, another colon and a comma separated list of options. The param configuration gets terminated by a closing curly bracket. Note that the type and option configuration are optional, but the name is mandatory.

To parse an expression shown above, use the PHP code as follows:

```
