PHPackages                             tourze/doctrine-function-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. tourze/doctrine-function-bundle

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

tourze/doctrine-function-bundle
===============================

A Symfony bundle that automatically registers custom Doctrine SQL functions from beberlei/doctrineextensions and tourze/doctrine-function-collection packages

1.0.1(6mo ago)023MITPHPCI passing

Since Apr 19Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/tourze/doctrine-function-bundle)[ Packagist](https://packagist.org/packages/tourze/doctrine-function-bundle)[ RSS](/packages/tourze-doctrine-function-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (17)Versions (6)Used By (0)

Doctrine Function Bundle
========================

[](#doctrine-function-bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/fab831059b58e07d0e2c02da435efe699208ec436e0f65ded295a3f6f58bc1e4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f646f637472696e652d66756e6374696f6e2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/doctrine-function-bundle)[![Total Downloads](https://camo.githubusercontent.com/b7bdf93629aaf7adb9a4e744d2881afc9e8b686deca6527723da4ab8a5a40da1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f646f637472696e652d66756e6374696f6e2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/doctrine-function-bundle)[![PHP Version](https://camo.githubusercontent.com/9a0d8f27234d2d5eacf031df8547a789637a68f318d688bf33e3083f9f6d9734/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f646f637472696e652d66756e6374696f6e2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/doctrine-function-bundle)[![License](https://camo.githubusercontent.com/8a90a15891396ce13582df18bddfb9586c5fb7897376a04d52d342422b0c6aaf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f646f637472696e652d66756e6374696f6e2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/doctrine-function-bundle)[![Tests](https://camo.githubusercontent.com/11493838a20ed6e432ede19716a1354016218bdaefc87bd89331c4f77264caec/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f75727a652f7068702d6d6f6e6f7265706f2f746573742e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/tourze/php-monorepo/actions)[![Code Coverage](https://camo.githubusercontent.com/6ce0146325478eb7cebae4cc6139b2af2c161735dd0e3c6ff6802f2c5a708179/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f7068702d6d6f6e6f7265706f3f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/php-monorepo)

A Symfony bundle that automatically registers custom Doctrine SQL functions from beberlei/doctrineextensions and tourze/doctrine-function-collection packages.

Features
--------

[](#features)

- **Zero Configuration**: Automatically registers 40+ custom SQL functions
- **Multiple Function Types**:
    - String functions (JSON\_EXTRACT, ANY\_VALUE, FIELD, FIND\_IN\_SET, etc.)
    - Datetime functions (DAY, MONTH, YEAR, HOUR, MINUTE, etc.)
    - Numeric functions (ACOS, SIN, TAN, POWER, RAND, etc.)
    - JSON functions (JSON\_ARRAY, JSON\_CONTAINS, JSON\_SEARCH, etc.)
- **Symfony Integration**: Seamlessly integrates with Doctrine ORM through compiler passes
- **Production Ready**: Fully tested and optimized for performance

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Symfony 6.4 or higher
- Doctrine ORM 3.0 or higher

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

[](#installation)

```
composer require tourze/doctrine-function-bundle
```

Quick Start
-----------

[](#quick-start)

1. Register the bundle in your Symfony application:

```
// config/bundles.php
return [
    // ...
    Tourze\DoctrineFunctionBundle\DoctrineFunctionBundle::class => ['all' => true],
];
```

2. Use the functions in your DQL queries:

```
use Doctrine\ORM\EntityManagerInterface;

// JSON functions
$query = $entityManager->createQuery('
    SELECT u FROM App\Entity\User u
    WHERE JSON_EXTRACT(u.metadata, "$.role") = :role
');
$query->setParameter('role', 'admin');

// String functions
$query = $entityManager->createQuery('
    SELECT p FROM App\Entity\Product p
    WHERE FIND_IN_SET(:category, p.categories) > 0
');
$query->setParameter('category', 'electronics');

// Datetime functions
$query = $entityManager->createQuery('
    SELECT o FROM App\Entity\Order o
    WHERE YEAR(o.createTime) = :year AND MONTH(o.createTime) = :month
');
$query->setParameters(['year' => 2023, 'month' => 12]);

// Numeric functions
$query = $entityManager->createQuery('
    SELECT p FROM App\Entity\Point p
    WHERE POWER(p.x, 2) + POWER(p.y, 2) < :radius
');
$query->setParameter('radius', 100);
```

Available Functions
-------------------

[](#available-functions)

### String Functions

[](#string-functions)

- `JSON_EXTRACT` - Extract data from JSON
- `JSON_SEARCH` - Search within JSON data
- `JSON_ARRAY` - Create JSON arrays
- `JSON_CONTAINS` - Check if JSON contains value
- `JSON_LENGTH` - Get JSON length
- `ANY_VALUE` - Get any value from group
- `FIELD` - Find field position
- `FIND_IN_SET` - Find value in comma-separated list
- `IFELSE` - Conditional expression
- `DATEDIFF` - Date difference
- `RAND` - Random string value

### Datetime Functions

[](#datetime-functions)

- `DAY` - Extract day from date
- `MONTH` - Extract month from date
- `YEAR` - Extract year from date
- `HOUR` - Extract hour from datetime
- `MINUTE` - Extract minute from datetime
- `WEEK` - Extract week from date
- `WEEKDAY` - Extract weekday from date

### Numeric Functions

[](#numeric-functions)

- `ACOS`, `ASIN`, `ATAN`, `ATAN2` - Trigonometric functions
- `COS`, `SIN`, `TAN` - Trigonometric functions
- `DEGREES`, `RADIANS` - Angle conversion
- `EXP`, `LOG`, `LOG10`, `LOG2` - Logarithmic functions
- `POWER`, `SQRT` - Power functions
- `CEIL`, `FLOOR`, `ROUND` - Rounding functions
- `PI`, `RAND` - Mathematical constants and random
- `BIT_COUNT`, `BIT_XOR` - Bit operations
- `STDDEV`, `VARIANCE` - Statistical functions

Testing
-------

[](#testing)

Run tests from the project root:

```
vendor/bin/phpunit packages/doctrine-function-bundle/tests
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance71

Regular maintenance activity

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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 ~52 days

Total

5

Last Release

186d ago

Major Versions

0.0.3 → 1.0.02025-11-01

### Community

Maintainers

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

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-doctrine-function-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-doctrine-function-bundle/health.svg)](https://phpackages.com/packages/tourze-doctrine-function-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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