PHPackages                             knplabs/rad-resource-resolver - 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. knplabs/rad-resource-resolver

AbandonedArchivedLibrary

knplabs/rad-resource-resolver
=============================

A routing resource resolver based on conventions

v2.2(8y ago)1255.0k3[1 issues](https://github.com/KnpLabs/rad-resource-resolver/issues)[2 PRs](https://github.com/KnpLabs/rad-resource-resolver/pulls)MITPHPPHP ~7.0

Since Feb 5Pushed 3y ago25 watchersCompare

[ Source](https://github.com/KnpLabs/rad-resource-resolver)[ Packagist](https://packagist.org/packages/knplabs/rad-resource-resolver)[ RSS](/packages/knplabs-rad-resource-resolver/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (9)Versions (15)Used By (0)

DEPRECATED
==========

[](#deprecated)

Unfortunately we decided to not maintain this project anymore ([see why](https://knplabs.com/en/blog/news-for-our-foss-projects-maintenance)). If you want to mark another package as a replacement for this one please send an email to .

Knp Rad Resource Resolver
=========================

[](#knp-rad-resource-resolver)

[![Build Status](https://camo.githubusercontent.com/0e38ba142ea8dbf1cd5bce934708e075f9426a265a2fbaffd16b88d0e22a626e/68747470733a2f2f7472617669732d63692e6f72672f4b6e704c6162732f7261642d7265736f757263652d7265736f6c7665722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/KnpLabs/rad-resource-resolver)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0845b572a151fc23981870c0e686b348de47df67022cdc0e1e80a774b05eb7e1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4b6e704c6162732f7261642d7265736f757263652d7265736f6c7665722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/KnpLabs/rad-resource-resolver/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/8b95b36b4062b1493b56467fb2785214585d90e39ae286571e9cd6fba835401c/68747470733a2f2f706f7365722e707567782e6f72672f6b6e706c6162732f7261642d7265736f757263652d7265736f6c7665722f762f737461626c65)](https://packagist.org/packages/knplabs/rad-resource-resolver) [![Total Downloads](https://camo.githubusercontent.com/e5e8d2948ee9a6e2792cc422ed7d32fb4a0b819249ddb4555a7639bf742d6582/68747470733a2f2f706f7365722e707567782e6f72672f6b6e706c6162732f7261642d7265736f757263652d7265736f6c7665722f646f776e6c6f616473)](https://packagist.org/packages/knplabs/rad-resource-resolver) [![Latest Unstable Version](https://camo.githubusercontent.com/dcf72af387ff6e71bbf3f58d5c81fbfd431232a8094cfdd3bf05250394903d8a/68747470733a2f2f706f7365722e707567782e6f72672f6b6e706c6162732f7261642d7265736f757263652d7265736f6c7665722f762f756e737461626c65)](https://packagist.org/packages/knplabs/rad-resource-resolver) [![License](https://camo.githubusercontent.com/8e8afdafa596eee9c609dbbbd05e30dee819fe4c7480c4e3737f581fe54c9ec0/68747470733a2f2f706f7365722e707567782e6f72672f6b6e706c6162732f7261642d7265736f757263652d7265736f6c7665722f6c6963656e7365)](https://packagist.org/packages/knplabs/rad-resource-resolver)

Official maintainers:
=====================

[](#official-maintainers)

- [@Einenlum](https://github.com/Einenlum)

Why using it?
-------------

[](#why-using-it)

Tired of doing the same things again and again in your controllers, like transforming a URL value in an object? Don't want to use ParamConverter Annotations?

This Resource Resolver is for you.

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

[](#installation)

With composer :

```
$ composer require knplabs/rad-resource-resolver
```

If you are using symfony2 you can update your `app/AppKernel.php` file:

```
public function registerBundles()
{
    $bundles = array(
        // bundles here ...
        new Knp\Rad\ResourceResolver\Bundle\ResourceResolverBundle(),
    );
}
```

How to use it?
--------------

[](#how-to-use-it)

In a yaml routing file, it could look like this :

```
    users_show:
        path: /users/{id}
        defaults:
            _resources:
                user:
                    service: my.user.repository
                    method: find
                    arguments: [$id]
    # This will automatically resolve the resource to give you a $user object in your request attributes
```

```
    countries_cities_buildings_index:
        path: /countries/{countryId}/cities/{citySlug}/buildings
        defaults:
            _resources:
                buildings:
                    service: app.building.repository
                    method: findByCountryAndCityAndActivity
                    arguments: [$countryId, $citySlug, "School"]
    # You will have a $buildings variable in your request attributes
```

Every `key` under `_resources` will be return as a `$key` converted value in your request attributes.

However, you can use more concise ways to express your resources configuration :

```
    product_show:
        path: /product/{slug}
        defaults:
            _resources:
                product: [ "my.repository.product:findBySlug", [ $slug ] ]
                bestSellers: "my.repository.seller:findBestSellers"
                # Supports invokable
                bestOffers: "my.repository.bestOffers"
                comments: ["my.repository.randomComments"]
                # Invokable with arguments
                relatedProducts: ["my.repository.relatedProducts", [10]]
```

Optional Resources
------------------

[](#optional-resources)

By default, the Rad Resource Resolver throws a `Symfony\Component\HttpKernel\Exception\NotFoundHttpException` if the resource was not found. You can override this behavior by adding the `required` option to false:

```
    _resources:
        buildings:
            service: app.building.repository
            method: findByCountryAndCityAndActivity
            arguments: [$countryId, $citySlug, "School"]
            required: false
```

Available resource resolving arguments
--------------------------------------

[](#available-resource-resolving-arguments)

- URL variables: you have to use the `$` prefix. For example, if your URL is `/products/{products}/` you can access to `product` value by using `$product`.
- Services: you can use the `@` prefix (ex: @doctrine)
- Previously resolved resources: you can use the `&` prefix (ex: `&user` will return the `user` resource)

How does it work?
-----------------

[](#how-does-it-work)

A `ResourcesListener` listens to `kernel.controller` event and resolves automatically all resources in `_resources`. The component uses `ParameterCaster` objects to catch different argument types and `Parser` objects to resolve \_resources locations syntax.

This means you can easily add your own `ParameterCasters` and `Parsers` to change the syntax used by the component.

To add your own `ParameterCaster`, just tag it with `knp_rad_resource_resolver.parameter_caster`. The tag to add a `Parser` is `knp_rad_resource_resolver.parser`.

Events
======

[](#events)

All events are listed [here](./src/Knp/Rad/ResourceResolver/Events.php).

How can I hook resource resolution ?
------------------------------------

[](#how-can-i-hook-resource-resolution-)

There is two events :

```
- knp_rad_resource_resolver.before_resource_resolved:  dispatched before the resolution. You can set the resource before the resolution.
- knp_rad_resource_resolver.resource_resolved:         dispatched after the resolution.

```

How can I get all resolved resources ?
--------------------------------------

[](#how-can-i-get-all-resolved-resources-)

There is a service alias named `knp_rad_resource_resolver.resource_container` where you can get all resolved resources. You can also listen to the event `knp_rad_resource_resolver.resource.added` and be notified when a resource is added to the container.

License
-------

[](#license)

This project is published under MIT License. Feel free to contribute.

###  Health Score

37

↑

LowBetter than 84% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 55.6% 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 ~87 days

Recently: every ~184 days

Total

12

Last Release

3104d ago

Major Versions

v1.4.1 → v2.0.02016-03-03

PHP version history (2 changes)v2.0.1PHP &gt;=5.4

v2.2PHP ~7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/202732?v=4)[KNP Labs](/maintainers/KnpLabs)[@KnpLabs](https://github.com/KnpLabs)

---

Top Contributors

[![PedroTroller](https://avatars.githubusercontent.com/u/1766827?v=4)](https://github.com/PedroTroller "PedroTroller (25 commits)")[![Djeg](https://avatars.githubusercontent.com/u/1638230?v=4)](https://github.com/Djeg "Djeg (11 commits)")[![Shivoham](https://avatars.githubusercontent.com/u/1434539?v=4)](https://github.com/Shivoham "Shivoham (3 commits)")[![polc](https://avatars.githubusercontent.com/u/3513348?v=4)](https://github.com/polc "polc (2 commits)")[![wysow](https://avatars.githubusercontent.com/u/632747?v=4)](https://github.com/wysow "wysow (1 commits)")[![alexpozzi](https://avatars.githubusercontent.com/u/8307861?v=4)](https://github.com/alexpozzi "alexpozzi (1 commits)")[![EVDW](https://avatars.githubusercontent.com/u/15868559?v=4)](https://github.com/EVDW "EVDW (1 commits)")[![akerouanton](https://avatars.githubusercontent.com/u/557933?v=4)](https://github.com/akerouanton "akerouanton (1 commits)")

### Embed Badge

![Health badge](/badges/knplabs-rad-resource-resolver/health.svg)

```
[![Health](https://phpackages.com/badges/knplabs-rad-resource-resolver/health.svg)](https://phpackages.com/packages/knplabs-rad-resource-resolver)
```

###  Alternatives

[kunstmaan/admin-bundle

The Kunstmaan Admin bundle supplies your project with a basic, elegant backend interface you can modify and extend so you can make your perfect admin module. The clean interface makes it straightforward for you and the people working with it to change settings and modify content.

58148.8k16](/packages/kunstmaan-admin-bundle)[setono/sylius-feed-plugin

Plugin to generate feeds within the Sylius ecommerce platform

26452.4k](/packages/setono-sylius-feed-plugin)[mapbender/mapbender

Mapbender library

10117.0k5](/packages/mapbender-mapbender)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

707.5k20](/packages/open-dxp-opendxp)

PHPackages © 2026

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