parsica-php/parsica
Parsica is a PHP parser combinator library for building custom parsers from small reusable pieces. Compose complex grammars with a fluent API, parse strings into structured results, and handle errors cleanly—ideal for DSLs, config formats, and language tooling.
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
<Tabs defaultValue="cli" values={[ { label: 'Command line', value: 'cli', }, { label: 'composer.json', value: 'composer', }, ] }> <TabItem value="cli">
composer require parsica-php/parsica
"require": {
"parsica-php/parsica": "dev-main"
}
(@TODO: add polyfill for mbstring).
In a .php file, make sure the Composer autoloader is included:
require_once __DIR__.'/../vendor/autoload.php';
Import parsers and combinators:
use function Parsica\Parsica\char;
You can combine multiple imports in one statement:
use function Parsica\Parsica\{between, char, atLeastOne, alphaChar};
Finally, add some code:
<?php
$parser = between(char('{'), char('}'), atLeastOne(alphaChar()));
$result = $parser->tryString("{Hello}");
echo $result->output();
// outputs "Hello"
How can I help you explore Laravel packages today?