PHPackages                             mtdowling/jmespath.php - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. mtdowling/jmespath.php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

mtdowling/jmespath.php
======================

Declaratively specify how to extract elements from a JSON document

2.9.1(3w ago)2.0k504.8M↓20.7%57[1 issues](https://github.com/jmespath/jmespath.php/issues)[2 PRs](https://github.com/jmespath/jmespath.php/pulls)20MITPHPPHP ^7.2.5 || ^8.0CI passing

Since Feb 19Pushed 3w ago20 watchersCompare

[ Source](https://github.com/jmespath/jmespath.php)[ Packagist](https://packagist.org/packages/mtdowling/jmespath.php)[ RSS](/packages/mtdowling-jmespathphp/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (6)Versions (23)Used By (20)Security (1)

jmespath.php
============

[](#jmespathphp)

JMESPath (pronounced "jaymz path") allows you to declaratively specify how to extract elements from a JSON document. *jmespath.php* allows you to use JMESPath in PHP applications with PHP data structures. It requires PHP 7.2.5 or greater and can be installed through [Composer](https://getcomposer.org/doc/00-intro.md)using the `mtdowling/jmespath.php` package.

```
require 'vendor/autoload.php';

$expression = 'foo.*.baz';

$data = [
    'foo' => [
        'bar' => ['baz' => 1],
        'bam' => ['baz' => 2],
        'boo' => ['baz' => 3]
    ]
];

JmesPath\search($expression, $data);
// Returns: [1, 2, 3]
```

- [JMESPath Tutorial](https://jmespath.org/tutorial.html)
- [JMESPath Grammar](https://jmespath.org/specification.html#grammar)
- [JMESPath Python library](https://github.com/jmespath/jmespath.py)

PHP Usage
---------

[](#php-usage)

The `JmesPath\search` function can be used in most cases when using the library. This function utilizes a JMESPath runtime based on your environment. The runtime utilized can be configured using environment variables.

```
$result = JmesPath\search($expression, $data);

// or, if you require PSR-4 compliance.
$result = JmesPath\Env::search($expression, $data);
```

### Runtimes

[](#runtimes)

jmespath.php utilizes *runtimes*. There are currently two runtimes: AstRuntime and CompilerRuntime.

AstRuntime is utilized by `JmesPath\search()` and `JmesPath\Env::search()` by default.

#### AstRuntime

[](#astruntime)

The AstRuntime will parse an expression, cache the resulting AST in memory, and interpret the AST using an external tree visitor. AstRuntime provides a good general approach for interpreting JMESPath expressions that have a low to moderate level of reuse.

```
$runtime = new JmesPath\AstRuntime();
$runtime('foo.bar', ['foo' => ['bar' => 'baz']]);
// > 'baz'
```

#### CompilerRuntime

[](#compilerruntime)

`JmesPath\CompilerRuntime` provides the most performance for applications that have a moderate to high level of reuse of JMESPath expressions. The CompilerRuntime will walk a JMESPath AST and emit PHP source code, resulting in anywhere from 7x to 60x speed improvements.

Compiling JMESPath expressions to source code is a slower process than just walking and interpreting a JMESPath AST (via the AstRuntime). However, running the compiled JMESPath code results in much better performance than walking an AST. This essentially means that there is a warm-up period when using the `CompilerRuntime`, but after the warm-up period, it will provide much better performance.

Use the CompilerRuntime if you know that you will be executing JMESPath expressions more than once or if you can pre-compile JMESPath expressions before executing them (for example, server-side applications).

```
// Note: The cache directory argument is optional.
$runtime = new JmesPath\CompilerRuntime('/path/to/compile/folder');
$runtime('foo.bar', ['foo' => ['bar' => 'baz']]);
// > 'baz'
```

##### Environment Variables

[](#environment-variables)

You can utilize the CompilerRuntime in `JmesPath\search()` by setting the `JP_PHP_COMPILE` environment variable to "on" or to a directory on disk used to store cached expressions.

Testing
-------

[](#testing)

A comprehensive list of test cases can be found at . These compliance tests are utilized by jmespath.php to ensure consistency with other implementations, and can serve as examples of the language.

jmespath.php is tested using PHPUnit. In order to run the tests, you need to first install the dependencies using Composer, then you just need to run the tests via make:

```
make test
```

You can run a suite of performance tests as well:

```
make perf
```

Security
--------

[](#security)

If you discover a security vulnerability within this package, follow the reporting process from our [Security Policy](https://github.com/jmespath/jmespath.php/security/policy).

License
-------

[](#license)

jmespath.php is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

79

—

ExcellentBetter than 100% of packages

Maintenance95

Actively maintained with recent releases

Popularity81

Widely adopted with strong download metrics

Community48

Growing community involvement

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 86.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~214 days

Recently: every ~456 days

Total

22

Last Release

22d ago

Major Versions

0.4.0 → 1.0.02014-06-19

1.1.x-dev → 2.0.02015-01-12

PHP version history (4 changes)0.1.0PHP &gt;=5.3.0

0.2.0PHP &gt;=5.4.0

2.6.0PHP ^5.4 || ^7.0 || ^8.0

2.7.0PHP ^7.2.5 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/190930?v=4)[Michael Dowling](/maintainers/mtdowling)[@mtdowling](https://github.com/mtdowling)

![](https://www.gravatar.com/avatar/184fbc398ff1b83855ab8289cd8ce20225d0158c66284b458d2d811546606938?d=identicon)[jeremeamia](/maintainers/jeremeamia)

![](https://www.gravatar.com/avatar/d95eb26cb8f3919bb5ca3b6d823daeabbf259663778a970349b245c580713c8e?d=identicon)[graham-campbell](/maintainers/graham-campbell)

---

Top Contributors

[![mtdowling](https://avatars.githubusercontent.com/u/190930?v=4)](https://github.com/mtdowling "mtdowling (436 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (53 commits)")[![nickfan](https://avatars.githubusercontent.com/u/100613?v=4)](https://github.com/nickfan "nickfan (2 commits)")[![jeremeamia](https://avatars.githubusercontent.com/u/107867?v=4)](https://github.com/jeremeamia "jeremeamia (1 commits)")[![Jubeki](https://avatars.githubusercontent.com/u/15707543?v=4)](https://github.com/Jubeki "Jubeki (1 commits)")[![kawaz](https://avatars.githubusercontent.com/u/156236?v=4)](https://github.com/kawaz "kawaz (1 commits)")[![mfn](https://avatars.githubusercontent.com/u/87493?v=4)](https://github.com/mfn "mfn (1 commits)")[![morozov](https://avatars.githubusercontent.com/u/59683?v=4)](https://github.com/morozov "morozov (1 commits)")[![mrtnmtth](https://avatars.githubusercontent.com/u/1316539?v=4)](https://github.com/mrtnmtth "mrtnmtth (1 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (1 commits)")[![siwinski](https://avatars.githubusercontent.com/u/1034024?v=4)](https://github.com/siwinski "siwinski (1 commits)")[![Chris53897](https://avatars.githubusercontent.com/u/7104259?v=4)](https://github.com/Chris53897 "Chris53897 (1 commits)")[![whatthejeff](https://avatars.githubusercontent.com/u/306525?v=4)](https://github.com/whatthejeff "whatthejeff (1 commits)")[![flavioheleno](https://avatars.githubusercontent.com/u/471860?v=4)](https://github.com/flavioheleno "flavioheleno (1 commits)")[![jamesls](https://avatars.githubusercontent.com/u/368057?v=4)](https://github.com/jamesls "jamesls (1 commits)")

---

Tags

jsonjsonpath

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mtdowling-jmespathphp/health.svg)

```
[![Health](https://phpackages.com/badges/mtdowling-jmespathphp/health.svg)](https://phpackages.com/packages/mtdowling-jmespathphp)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B13.9k](/packages/symfony-console)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[symfony/http-foundation

Defines an object-oriented layer for the HTTP specification

8.7k928.6M6.5k](/packages/symfony-http-foundation)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k251.7M11.6k](/packages/symfony-framework-bundle)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[symfony/security-http

Symfony Security Component - HTTP Integration

1.7k177.2M382](/packages/symfony-security-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
