PHPackages                             shipmonk/doctrine-hint-driven-sql-walker - 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. shipmonk/doctrine-hint-driven-sql-walker

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

shipmonk/doctrine-hint-driven-sql-walker
========================================

Doctrine's SqlWalker that allows hooking multiple handlers via -&gt;setHint() while each can edit produced SQL or its part.

2.0.2(1y ago)4419.5k↓52.6%12MITPHPPHP ^8.1CI passing

Since Jan 23Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/shipmonk-rnd/doctrine-hint-driven-sql-walker)[ Packagist](https://packagist.org/packages/shipmonk/doctrine-hint-driven-sql-walker)[ RSS](/packages/shipmonk-doctrine-hint-driven-sql-walker/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (14)Versions (7)Used By (2)

SqlWalker for Doctrine allowing multiple handlers to modify resulting SQL
-------------------------------------------------------------------------

[](#sqlwalker-for-doctrine-allowing-multiple-handlers-to-modify-resulting-sql)

Since Doctrine's [SqlWalker](https://www.doctrine-project.org/projects/doctrine-orm/en/3.3/cookbook/dql-custom-walkers.html#modify-the-output-walker-to-generate-vendor-specific-sql) serves as a translator from DQL AST to SQL, it becomes problematic when you want to alter resulting SQL within multiple libraries by such approach. There just can be only single SqlWalker.

This library solves this issue, by providing `HintHandler` base class which is designed for SQL modification and can be used multiple times in `$queryBuilder->setHint()`.

### Installation:

[](#installation)

```
composer require shipmonk/doctrine-hint-driven-sql-walker
```

### Usage:

[](#usage)

```
$queryBuilder
    ->getQuery()
    ->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, HintDrivenSqlWalker::class)
    ->setHint(MaxExecutionTimeHintHandler::class, 1000)
```

Where `MaxExecutionTimeHintHandler` just extends our `HintHandler` and picks some `SqlNode` to hook to and alters appropriate SQL part:

```
class MaxExecutionTimeSqlWalker extends HintHandler
{

    public function getNodes(): array
    {
        return [SqlNode::SelectClause];
    }

    public function processNode(
        SqlNode $sqlNode,
        string $sql,
    ): string
    {
        // grab the 1000 passed to ->setHint()
        $milliseconds = $this->getHintValue();

        // edit SQL as needed
        return preg_replace(
            '~^SELECT (.*?)~',
            "SELECT /*+ MAX_EXECUTION_TIME($milliseconds) */ \\1 ",
            $sql
        );
    }
```

SqlNode is an enum of all `walkXxx` methods in Doctrine's SqlWalker, so you are able to intercept any part of AST processing the SqlWalker does.

### Limitations

[](#limitations)

- Please note that since [doctrine/orm 3.3.0](https://github.com/doctrine/orm/pull/11188), the produced SQL gets finalized with `LIMIT` / `OFFSET` / `FOR UPDATE` after `SqlWalker` processing is done.
    - Thus, implementors should be aware that those SQL parts can be appended to the SQL after `HintHandler` processing.
    - This means that e.g. placing a comment at the end of the SQL breaks LIMIT functionality completely

### Implementors

[](#implementors)

- [shipmonk/doctrine-mysql-optimizer-hints](https://github.com/shipmonk-rnd/doctrine-mysql-optimizer-hints) (since v2)
- [shipmonk/doctrine-mysql-index-hints](https://github.com/shipmonk-rnd/doctrine-mysql-index-hints) (since v3)

### Compatibility

[](#compatibility)

VersionPHP Compatibilitydoctrine/ormv17.2 - 8.32.xv28.1 - 8.43.x

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance56

Moderate activity, may be stable

Popularity41

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.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 ~93 days

Total

4

Last Release

612d ago

Major Versions

1.0.0 → 2.0.02024-08-08

PHP version history (2 changes)1.0.0PHP ^7.2 || ^8.0

2.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b545e3f9d982d538f11bc42b3dc2d186f706cef92c8bc8bc8f8788b08186ea5?d=identicon)[janedbal](/maintainers/janedbal)

![](https://www.gravatar.com/avatar/7a4170ebe9281cb76be91fe00f8eee307beb3e0744dfd40ba89d9c856372c7eb?d=identicon)[shipmonk](/maintainers/shipmonk)

---

Top Contributors

[![janedbal](https://avatars.githubusercontent.com/u/1993453?v=4)](https://github.com/janedbal "janedbal (36 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (13 commits)")[![JanTvrdik](https://avatars.githubusercontent.com/u/175109?v=4)](https://github.com/JanTvrdik "JanTvrdik (4 commits)")[![gharlan](https://avatars.githubusercontent.com/u/330436?v=4)](https://github.com/gharlan "gharlan (1 commits)")

---

Tags

doctrineormquerybuilder

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/shipmonk-doctrine-hint-driven-sql-walker/health.svg)

```
[![Health](https://phpackages.com/badges/shipmonk-doctrine-hint-driven-sql-walker/health.svg)](https://phpackages.com/packages/shipmonk-doctrine-hint-driven-sql-walker)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M386](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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