PHPackages                             nzour/symfony-advanced-resolving - 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. nzour/symfony-advanced-resolving

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

nzour/symfony-advanced-resolving
================================

v1.0.0(3y ago)05PHPPHP &gt;=8.0

Since Jun 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/nzour/symfony-advanced-resolving)[ Packagist](https://packagist.org/packages/nzour/symfony-advanced-resolving)[ RSS](/packages/nzour-symfony-advanced-resolving/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (10)Versions (3)Used By (0)

Symfony advanced resolving
==========================

[](#symfony-advanced-resolving)

### Requirements

[](#requirements)

- php &gt;= 8.0
- symfony &gt;= 5.3

### Installation

[](#installation)

```
composer require nzour/symfony-advanced-resolving

```

**Important**: Make sure bundle `\AdvancedResolving\AdvancedResolvingBundle` become enabled, otherwise enable it in `bundles.php`

### Examples

[](#examples)

\#1 Using **\#\[FromQuery\]** attribute:

```
#[AsController, Route(path: '/foo')]
final class FooController
{
    #[Route(methods: ['GET'])]
    public static function index(#[FromQuery] string $value): JsonResponse
    {
        return new JsonResponse([
            'value' => $value,
        ]);
    }
}
```

`GET {host}/foo?value={value}`

---

\#2 Using **\#\[FromQuery\]** attribute with different param name:

```
#[AsController, Route(path: '/foo')]
final class FooController
{
    #[Route(methods: ['GET'])]
    public static function index(
        #[FromQuery(paramName: 'foobar')] string $value,
        #[FromQuery] int $score,
    ): JsonResponse {
        return new JsonResponse([
            'value' => $value,
            'score' => $score,
        ]);
    }
}
```

`GET {host}/foo?foobar={value}&score={score}`

---

\#3 Using **\#\[FromQuery\]** with class typehint

```
final class FooQuery
{
    public function __construct(
        public string $value,
        public int $score,
    ) {
    }
}

#[AsController, Route(path: '/foo')]
final class FooController
{
    #[Route(methods: ['GET'])]
    public static function index(#[FromQuery] FooQuery $fooQuery): JsonResponse {
        return new JsonResponse($fooQuery);
    }
}
```

`GET {host}/foo?value={value}&score={score}`

*Note*: it's not possible to rename properties of **FooQuery** via additional attributes

---

\#4 Using **\#\[FromBody\]**

```
final class FooCommand
{
    public function __construct(
        public string $foobar,
        public int $barfoo,
    ) {
    }
}

#[AsController, Route(path: '/foo')]
final class FooController
{
    #[Route(methods: ['POST'])]
    public static function command(#[FromBody] FooCommand $command): JsonResponse
    {
        return new JsonResponse([
            'command' => $command,
        ]);
    }
}
```

### Docs

[](#docs)

Feature based on **Symfony's ArgumentValueResolver** flow, therefore make sure your controllers tagged with `controller.service_arguments` or marked via `#[AsController]` attribute.

##### Built in

[](#built-in)

- `bin/console debug:meta-resolvers` - View list of defined meta resolvers
- **FromBody**

    Implementation class [FromBodyMetaResolver](https://github.com/nzour/symfony-advanced-resolving/blob/master/src/Core/Resolver/FromBodyMetaResolver.php)

    Uses symfony serializer to instantiate objects from plain data, default format of data is **json**. There is a way to specify another format: `#[FromBody(format: XmlEncoder::FORMAT)]`. It is not possible to change format globally.
- **FromQuery**

    Implementation class [FromQueryMetaResolver](https://github.com/nzour/symfony-advanced-resolving/blob/master/src/Core/Resolver/FromQueryMetaResolver.php)

    You can specify different param name `#[FromQuery(paramName: 'foobar')]`

    Parameter **FromQuery::$disableTypeEnforcement** is responsible for flag **AbstractObjectNormalizer::DISABLE\_TYPE\_ENFORCEMENT** when resolve object. It's value **true** by default.

##### Not implemented yet

[](#not-implemented-yet)

- FromHeader
- FromForm

##### Errors

[](#errors)

- [Symfony Serializer's Exceptions](https://symfony.com/doc/current/components/serializer.html)
- [NonNullableArgumentWithNoDefaultValueFromQueryParamsException](https://github.com/nzour/symfony-advanced-resolving/blob/master/src/Core/Exception/NonNullableArgumentWithNoDefaultValueFromQueryParamsException.php) - Only for **\#\[FromQuery\]**. Argument is not nullable, has no default value and there is also no value specified from request
- [CouldNotCreateInstanceFromQueryParamsException](https://github.com/nzour/symfony-advanced-resolving/blob/master/src/Core/Exception/CouldNotCreateInstanceFromQueryParamsException.php) - Just like above, but if argument's typehint is class

##### Extend by user land

[](#extend-by-user-land)

If you want to create your own attribute and algoritm that resolves it, follow steps:

- Define your attribute or use existing attribute
- Define class-service, that implements **MetaResolverInterface**
- Method **supportedAttribute** should return **class-string** of which attribute it supports
- Mark your service with tag `meta-resolver`

### Limitations

[](#limitations)

- Built in resolvers work with [Symfony Serializer](https://symfony.com/doc/current/components/serializer.html)
- No interop with [Symfony Validator](https://symfony.com/doc/current/components/validator.html) (yet, or maybe not yet)
- Built in attributes work only with endpoint's parameters, it's not possible to combine attributes:

    ```
    final class FooDto
    {
        public function __construct(
           #[FromQuery]
           public string $foobar,
           public int $barfoo,
       ) {
       }
    }

    #[AsController]
    final class FooController
    {
        #[Route(path: '/foo', methods: ['POST'])
        public function index(#[FromBody] FooDto $dto): void
        {
         // ...
        }
    }
    ```

    The entire class **FooDto** would be compiled from Body parameters.

    However property **FooDto::$foobar** is marked with attribute **\#\[FromQuery\]**, resolver would not try to find parameter **foobar** inside query-parameters and try set it as property's value.

### Inspired by

[](#inspired-by)

- [Model Binding in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/mvc/models/model-binding?view=aspnetcore-6.0)
- [NestJs param decorators](https://docs.nestjs.com/custom-decorators#param-decorators)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Total

2

Last Release

1436d ago

### Community

Maintainers

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

---

Top Contributors

[![nzour](https://avatars.githubusercontent.com/u/45079391?v=4)](https://github.com/nzour "nzour (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nzour-symfony-advanced-resolving/health.svg)

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

###  Alternatives

[eureka2/g6k

Generator of simulator of calculation (calculator)

235.5k](/packages/eureka2-g6k)

PHPackages © 2026

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