PHPackages                             morphql/morphql-symfony - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. morphql/morphql-symfony

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

morphql/morphql-symfony
=======================

Symfony integration for MorphQL — YAML config, autowiring, and .morphql file convention

v0.1.45(1mo ago)010MITPHPPHP &gt;=8.1

Since Feb 12Pushed 1mo agoCompare

[ Source](https://github.com/Hyperwindmill/morphql-symfony)[ Packagist](https://packagist.org/packages/morphql/morphql-symfony)[ Docs](https://github.com/Hyperwindmill/morphql-symfony)[ RSS](/packages/morphql-morphql-symfony/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (36)Versions (26)Used By (0)

MorphQL Symfony
===============

[](#morphql-symfony)

Symfony integration for [MorphQL](https://github.com/Hyperwindmill/morphql) — transform data with declarative queries.

**YAML configuration · Autowiring · Twig-style file convention · PHP 8.1+**

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

[](#installation)

```
composer require morphql/morphql-symfony
```

With **Symfony Flex** (Currently waiting for submission to [symfony/recipes-contrib](https://github.com/symfony/recipes-contrib)), this will automatically:

- Registers `MorphQLBundle` in `bundles.php`
- Creates `config/packages/morphql.yaml` with sensible defaults
- Scaffolds the `morphql-queries/` directory at your project root

> Without Flex, you could have to register the bundle manually in `config/bundles.php` (depends on your Symfony version):
>
> ```
> MorphQL\SymfonyBundle\MorphQLBundle::class => ['all' => true],
> ```

**The bundle is fully zero-config.** All settings have sensible defaults — no YAML file is needed to get started. Just install, drop a `.morphql` file in `morphql-queries/`, and you're ready to go.

Configuration (optional)
------------------------

[](#configuration-optional)

To customize behavior, create or edit `config/packages/morphql.yaml`:

```
morphql:
  # Execution provider: "cli" (bundled Node.js engine) or "server" (remote REST API)
  # provider: cli

  # Directory containing .morphql query files
  # query_dir: '%kernel.project_dir%/morphql-queries'

  # Server provider settings (uncomment if using provider: server)
  # server_url: '%env(MORPHQL_SERVER_URL)%'
  # api_key: '%env(MORPHQL_API_KEY)%'
```

All options have sensible defaults — zero-config works out of the box.

### Full Configuration Reference

[](#full-configuration-reference)

OptionDefaultDescription`provider``cli``cli` (bundled Node.js) or `server` (remote REST API)`cli_path`*(auto)*Override CLI binary path`node_path``node`Path to Node.js binary`cache_dir``%kernel.cache_dir%/morphql`Compiled query cache`query_dir``%kernel.project_dir%/morphql-queries``.morphql` file directory`server_url``http://localhost:3000`MorphQL server URL`api_key`—API key for server auth`timeout``30`Execution timeout (seconds)Usage
-----

[](#usage)

### 1. The `morphql-queries/` directory

[](#1-the-morphql-queries-directory)

Like Twig templates in `templates/`, you can store your MorphQL queries in `morphql-queries/`. Use the `.morphql` extension for syntax highlighting in supported IDEs.

```
morphql-queries/
├── invoices/
│   └── to_xml.morphql        # Identifier: 'invoices/to_xml'
└── api_response.morphql      # Identifier: 'api_response'

```

### 2. Using the Transformation Registry

[](#2-using-the-transformation-registry)

Inject the `TransformationRegistry` to run queries stored in files:

```
use MorphQL\SymfonyBundle\TransformationRegistry;

class InvoiceService
{
    public function __construct(
        private readonly TransformationRegistry $registry
    ) {}

    public function process(array $data): string
    {
        // Resolves to morphql-queries/invoices/to_xml.morphql
        return $this->registry->transform('invoices/to_xml', $data);
    }
}
```

### 3. Direct MorphQL usage

[](#3-direct-morphql-usage)

For ad-hoc queries, you can inject the base `MorphQL` service:

```
use MorphQL\MorphQL;

class MyController
{
    public function __construct(
        private readonly MorphQL $morphql
    ) {}

    public function index(string $json): string
    {
        return $this->morphql->run('from json to json transform set x = 1', $json);
    }
}
```

Features
--------

[](#features)

- **Symfony Flex Recipe**: Automatic bundle registration, config scaffolding, and query directory creation.
- **Filesystem Discovery**: Use standard paths like `'sub/folder/query'` — no dot-notation required.
- **Pre-configured**: The `MorphQL` service is automatically configured from your YAML settings.
- **Isomorphic**: Switch between `cli` and `server` providers via config without changing your code.

Symfony Flex Recipe
-------------------

[](#symfony-flex-recipe)

The recipe files are staged in the [`recipe/`](./recipe/) directory and need to be submitted to [`symfony/recipes-contrib`](https://github.com/symfony/recipes-contrib) for Flex to pick them up automatically.

To submit the recipe:

1. Fork [symfony/recipes-contrib](https://github.com/symfony/recipes-contrib)
2. Create `morphql/morphql-symfony/0.1/` in the fork
3. Copy the contents of `recipe/` into that directory
4. Open a Pull Request following the [recipe contribution guide](https://github.com/symfony/recipes/blob/main/RECIPES.md)

Until the recipe is accepted, users can manually:

- Create `config/packages/morphql.yaml` (copy from `recipe/config/packages/morphql.yaml`)
- Create the `morphql-queries/` directory at their project root

Troubleshooting
---------------

[](#troubleshooting)

### "node" not found

[](#node-not-found)

If you use a version manager like **NVM**, **asdf**, or **Volta**, the `node` binary might not be in the default `PATH` used by your web server or PHP process.

**Solution 1: Set the path in .env**

```
MORPHQL_NODE_PATH=/usr/local/bin/node # Use 'which node' to find yours
```

**Solution 2: Create a system symlink**

```
sudo ln -s $(which node) /usr/local/bin/node
```

Prerequisites
-------------

[](#prerequisites)

- **PHP 8.1+**
- **Node.js 18+** (for the `cli` provider)
- **Symfony 5.4+**, **6.x**, **7.x**, or **8.x**

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance92

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

Total

25

Last Release

39d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7858a7f66072d25c39092eb95197704fbc02812fde775ed0ffcc86b34b67ad94?d=identicon)[hyperwindmill](/maintainers/hyperwindmill)

---

Top Contributors

[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

symfonybundletransformdata transformationmorphql

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/morphql-morphql-symfony/health.svg)

```
[![Health](https://phpackages.com/badges/morphql-morphql-symfony/health.svg)](https://phpackages.com/packages/morphql-morphql-symfony)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[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)
