PHPackages                             fabianofa/jsonboperators-bundle - 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. [Database &amp; ORM](/categories/database)
4. /
5. fabianofa/jsonboperators-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

fabianofa/jsonboperators-bundle
===============================

Symfony Bundle of Doctrine custom functions that allows the developer to use -&gt;, -&gt;&gt; and #&gt;&gt; operators in DQL

v1.2(8y ago)021MITPHPPHP &gt;=7.0

Since Jan 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/fabianofa/JsonbOperatorsBundle)[ Packagist](https://packagist.org/packages/fabianofa/jsonboperators-bundle)[ Docs](https://github.com/fabianofa/JsonbBundle)[ RSS](/packages/fabianofa-jsonboperators-bundle/feed)WikiDiscussions master Synced 2mo ago

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

JsonbOperatorsBundle
--------------------

[](#jsonboperatorsbundle)

PostgreSQL 9.4 introduced the new data type jsonb. With it some documented operators such as -&gt;, -&gt;&gt; and #&gt;&gt;{} are available to access or retrieve values within a jsonb column data. Since Symfony uses Doctrine as default and Doctrine uses its own query language DQL, the operators aren't available natively. You can also [visit PostgreSQL json function and operator documentation](https://www.postgresql.org/docs/current/static/functions-json.html) to check which operator you expect to use.

This bundle adds some custom functions to allow developers to use such operators.

1. Installation
2. Adding custom functions to config.yml
3. Documentation
4. Planned improvements

1. Installation
===============

[](#1-installation)

---

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require fabianofa/jsonboperators-bundle
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

2. Adding custom functions to config.yml(php/xml)
=================================================

[](#2-adding-custom-functions-to-configymlphpxml)

---

You must add the new functions to be used with DQL into your project's config.yml file, or equivalent if you're using XML, annotations or PHP for config files. If any of the structure is already declared, just append the missing settings.

```
doctrine:
   orm:
        dql:
            string_functions:
                jsonbbykey: fabianofa\JsonbOperatorsBundle\Doctrine\Query\JsonbByKey
                jsonbbykeytext: fabianofa\JsonbOperatorsBundle\Doctrine\Query\JsonbByKeyText
                jsonbbypath: fabianofa\JsonbOperatorsBundle\Doctrine\Query\JsonbByPath

```

3. Documentation
================

[](#3-documentation)

---

From now on you can call one of the functions in your query builder definition in methods as `select` or `andWhere`/`where`, such as:

```
$query = $entityManager->createQueryBuilder("f")
                        ->from("AppBundle:Entity", "e")
                        ->select("jsonbbykeytext(jsoncolumn, 'jsonpropertykey')")
                        ->where("e.id = :id")
                        ->setParameter(":id", 5);

```

Functions and operators:
------------------------

[](#functions-and-operators)

- All functions take two parameters.
- The first parameter is the column name typed as jsonb
- The second parameter can be:
    - a single parameter value. Eg: `jsonbbykeytext(jsonbcolumn, 'key')`
    - a string containing a path of json keys separated by comma (,): Eg: `jsonbbypath(jsonbcolumn, 'key1,key2')`

### jsonbykey()

[](#jsonbykey)

##### Example 1 (single key):

[](#example-1-single-key)

DQL: `->select("jsonbykey(jsonbcolumn, 'key')`

SQL Equivalent: `SELECT jsonbcolumn->'key' FROM ...`

##### Example 2 (multiple keys):

[](#example-2-multiple-keys)

DQL: `->select("jsonbykey(jsonbcolumn, 'key,key2')`

SQL Equivalent: `SELECT jsonbcolumn->'key'->'key2' FROM ...`

---

### jsonbykeytext()

[](#jsonbykeytext)

##### Example 1 (single key):

[](#example-1-single-key-1)

DQL: `->select("jsonbykeytext(jsonbcolumn, 'key')`

SQL Equivalent: `SELECT jsonbcolumn->>'key' FROM ...`

##### Example 2 (multiple keys):

[](#example-2-multiple-keys-1)

DQL: `->select("jsonbykeytext(jsonbcolumn, 'key,key2')`

SQL Equivalent: `SELECT jsonbcolumn->>'key'->>'key2' FROM ...`

---

### jsonbbypath()

[](#jsonbbypath)

##### Example 1 (single key):

[](#example-1-single-key-2)

DQL: `->select("jsonbbypath(jsonbcolumn, 'key')`

SQL Equivalent: `SELECT jsonbcolumn#>>'{key}' FROM ...`

##### Example 2 (multiple keys):

[](#example-2-multiple-keys-2)

DQL: `->select("jsonbykeytext(jsonbcolumn, 'key,key2')`

SQL Equivalent: `SELECT jsonbcolumn#>>'{key, key2}' FROM ...`

---

Planned improvements
====================

[](#planned-improvements)

There are more operators listed in the official PostgreSQL documentation. The goal is to offer all the operators available. Some native functions may be already be implemented in Doctrine therefore you're encourage to use the native solution instead this package.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

3

Last Release

3053d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f56a2d9829d50be7ba41e0977373ab7aa91cb8dd6dfe1e0cab9f7ba8a04b9752?d=identicon)[fabianofa](/maintainers/fabianofa)

---

Top Contributors

[![fabianofa](https://avatars.githubusercontent.com/u/3268899?v=4)](https://github.com/fabianofa "fabianofa (11 commits)")

---

Tags

symfonybundledoctrinefunctionjsonboperatorfabianofa

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fabianofa-jsonboperators-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/fabianofa-jsonboperators-bundle/health.svg)](https://phpackages.com/packages/fabianofa-jsonboperators-bundle)
```

###  Alternatives

[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M155](/packages/sonata-project-doctrine-orm-admin-bundle)[omines/datatables-bundle

Symfony DataTables Bundle with native Doctrine ORM, Elastica and MongoDB support

2851.4M6](/packages/omines-datatables-bundle)[boldtrn/jsonb-bundle

A library adding the support for JSONB columns of PostgreSQL to Doctrine.

57817.6k](/packages/boldtrn-jsonb-bundle)[onurb/doctrine-yuml-bundle

Symfony Bundle to visualize the mapping of your entities with Yuml

4198.6k](/packages/onurb-doctrine-yuml-bundle)[kucharovic/money-bundle

This bundle provides integration for Money library in your Symfony project.

2253.7k](/packages/kucharovic-money-bundle)

PHPackages © 2026

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