tourze/doctrine-function-bundle

Doctrine函数增强模块

0.0.1 2025-04-19 07:39 UTC

This package is auto-updated.

Last update: 2025-04-25 19:14:02 UTC


README

English | 中文

Latest Version Total Downloads

A Symfony bundle for registering custom Doctrine SQL functions.

Features

  • Automatically registers custom SQL functions for Doctrine ORM
  • Supports multiple function types:
    • String functions (JSON_EXTRACT, ANY_VALUE, etc.)
    • Datetime functions (DAY, MONTH, YEAR, etc.)
    • Numeric functions (ACOS, SIN, TAN, etc.)
  • Zero configuration required
  • Integrates with Doctrine ORM

Installation

composer require tourze/doctrine-function-bundle

Quick Start

  1. Register the bundle in your Symfony application:
// config/bundles.php
return [
    // ...
    Tourze\DoctrineFunctionBundle\DoctrineFunctionBundle::class => ['all' => true],
];
  1. No additional configuration needed - all functions are automatically registered.

  2. Use the functions in your DQL queries:

$query = $entityManager->createQuery('
    SELECT e FROM AppBundle:Entity e 
    WHERE JSON_EXTRACT(e.data, "$.property") = :value
');
$query->setParameter('value', 'test');

Testing

Run PHPUnit from the project root:

vendor/bin/phpunit -c phpunit.xml packages/doctrine-function-bundle/tests

License

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