PHPackages                             hec-franco/doctrine-json-functions - 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. hec-franco/doctrine-json-functions

ActiveLibrary[Database &amp; ORM](/categories/database)

hec-franco/doctrine-json-functions
==================================

A set of extensions to Doctrine that add support for json query functions.

5.4.1(2y ago)09MITPHPPHP ^8.1

Since Feb 8Pushed 2y agoCompare

[ Source](https://github.com/HecFranco/DoctrineJsonFunctions)[ Packagist](https://packagist.org/packages/hec-franco/doctrine-json-functions)[ RSS](/packages/hec-franco-doctrine-json-functions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (2)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/3ff6d8b0d971d1462dc43b49d45d16db32207d84c8105df6188e7b91e996e598/68747470733a2f2f706f7365722e707567782e6f72672f736369656e74612f646f637472696e652d6a736f6e2d66756e6374696f6e732f762f737461626c653f666f726d61743d666c6174)](https://packagist.org/packages/scienta/doctrine-json-functions)[![Total Downloads](https://camo.githubusercontent.com/0c1dc3b9e24fa0aadcf113c5217544a57105b400a6e03016936b448218045ff4/68747470733a2f2f706f7365722e707567782e6f72672f736369656e74612f646f637472696e652d6a736f6e2d66756e6374696f6e732f646f776e6c6f6164733f666f726d61743d666c6174)](https://packagist.org/packages/scienta/doctrine-json-functions)[![License](https://camo.githubusercontent.com/a12545eb84d2cdf9ab6bbcd5622487a9a48f63e45cd273721ca76c0d54da15e1/68747470733a2f2f706f7365722e707567782e6f72672f736369656e74612f646f637472696e652d6a736f6e2d66756e6374696f6e732f6c6963656e7365)](https://packagist.org/packages/scienta/doctrine-json-functions)

DoctrineJsonFunctions
=====================

[](#doctrinejsonfunctions)

A set of extensions to Doctrine 2 that add support for json query functions. +Functions are available for MySQL, MariaDb and PostgreSQL.

DBFunctionsMySQL`JSON_APPEND, JSON_ARRAY, JSON_ARRAYAGG, JSON_ARRAY_APPEND, JSON_ARRAY_INSERT, JSON_CONTAINS, JSON_CONTAINS_PATH, JSON_DEPTH, JSON_EXTRACT, JSON_OVERLAPS, JSON_INSERT, JSON_KEYS, JSON_LENGTH, JSON_MERGE, JSON_MERGE_PRESERVE, JSON_MERGE_PATCH, JSON_OBJECT, JSON_OBJECTAGG, JSON_PRETTY, JSON_QUOTE, JSON_REMOVE, JSON_REPLACE, JSON_SEARCH, JSON_SET, JSON_TYPE, JSON_UNQUOTE, JSON_VALID`PostgreSQL`JSON_EXTRACT_PATH, GT, GT_GT, SHARP_GT, SHARP_GT_GT`MariaDb`JSON_VALUE, JSON_EXISTS, JSON_QUERY, JSON_COMPACT, JSON_DETAILED, JSON_LOOSE, JSON_EQUALS, JSON_NORMALIZE`SQLite`JSON, JSON_ARRAY, JSON_ARRAY_LENGTH, JSON_EXTRACT, JSON_GROUP_ARRAY, JSON_GROUP_OBJECT, JSON_INSERT, JSON_OBJECT, JSON_PATCH, JSON_QUOTE, JSON_REMOVE, JSON_REPLACE, JSON_SET, JSON_TYPE, JSON_VALID`Table of Contents
-----------------

[](#table-of-contents)

- [Changelog per release](#changelog)
- [Installation](#installation)
- [Testing](#testing)
- [Functions Registration](#functions-registration)
    - [Doctrine](#doctrine-orm)
    - [Symfony](#symfony-with-doctrine-bundle)
- [Usage](#usage)
    - [Using Mysql 5.7+ JSON operators](#using-mysql-57-json-operators)
    - [Using PostgreSQL 9.3+ JSON operators](#using-postgresql-93-json-operators)
    - [Using SQLite JSON operators](#using-sqlite-json-operators)
- [DQL Functions](#dql-functions)
    - [Mysql 5.7+ JSON operators](#mysql-57-json-operators)
    - [PostgreSQL 9.3+ JSON operators](#postgresql-93-json-operators)
    - [SQLite json1 extension operators](#sqlite-json1-extension-operators)
- [Extendability and Database Support](#extendability-and-database-support)
    - [Architecture](#architecture)
    - [Adding new platform](#adding-a-new-platform)
    - [Adding new function](#adding-a-new-function)

Changelog
---------

[](#changelog)

Changes per release are documented with each github release. You can find an overview here:

Installation
------------

[](#installation)

The recommended way to install DoctrineJsonFunctions is through [Composer](https://getcomposer.org/). Add the following dependency to your composer.json

```
{
	"require": {
		"scienta/doctrine-json-functions": "~5"
	}
}
```

Alternatively, you can download the [source code as a file](https://github.com/ScientaNL/DoctrineJsonFunctions/releases) and extract it.

Testing
-------

[](#testing)

This repository uses phpunit for testing purposes. If you just want to run the tests you can use the docker composer image to install and run phpunit. There is a docker-compose file with the correct mount but if you want to use just docker you can run this:

### php8

[](#php8)

```
docker run -it -v ${PWD}:/app scienta/php-composer:php8 /bin/bash -c "composer install && ./vendor/bin/phpunit"
```

Functions Registration
----------------------

[](#functions-registration)

### Doctrine ORM

[](#doctrine-orm)

[Doctrine documentation: "DQL User Defined Functions"](http://docs.doctrine-project.org/en/latest/cookbook/dql-user-defined-functions.html)

```
