PHPackages                             kleijnweb/php-api-routing-bundle - 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. [API Development](/categories/api)
4. /
5. kleijnweb/php-api-routing-bundle

AbandonedArchivedSymfony-bundle[API Development](/categories/api)

kleijnweb/php-api-routing-bundle
================================

Symfony routing using php-api-descriptions

v1.0.0-alpha1(9y ago)26.7k2LGPL-3.0PHPPHP ^7.0.0

Since May 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/kleijnweb/php-api-routing-bundle)[ Packagist](https://packagist.org/packages/kleijnweb/php-api-routing-bundle)[ RSS](/packages/kleijnweb-php-api-routing-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (24)Versions (2)Used By (0)

This project is no longer maintained
====================================

[](#this-project-is-no-longer-maintained)

KleijnWeb\\PhpApi\\RoutingBundle
================================

[](#kleijnwebphpapiroutingbundle)

[![SensioLabsInsight](https://camo.githubusercontent.com/5c07359e22a583f5c2d7a16e50b010d46d503ac14ae780516a076b5b57136e27/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31646130643831612d373863352d346265372d383232382d3732393633633066366432342f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/1da0d81a-78c5-4be7-8228-72963c0f6d24)

[![Build Status](https://camo.githubusercontent.com/758d0251b1fde65715130c207d0051d07807ed7402d4d714ab6b8900a9c110eb/68747470733a2f2f7472617669732d63692e6f72672f6b6c65696a6e7765622f7068702d6170692d726f7574696e672d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kleijnweb/php-api-routing-bundle)[![Coverage Status](https://camo.githubusercontent.com/13d4a0be448986146164ebe2f844ac405fc3e352d30ed8e76ec7aaf4753f17f8/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6b6c65696a6e7765622f7068702d6170692d726f7574696e672d62756e646c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/kleijnweb/php-api-routing-bundle?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/20c5462c45ecab77ccff887bc63a151acefcda8d0000f6f7e620d955cbfbb32e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6c65696a6e7765622f7068702d6170692d726f7574696e672d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kleijnweb/php-api-routing-bundle/?branch=master)[![Latest Unstable Version](https://camo.githubusercontent.com/fcab56e91c699a4062c509693e9ff96378d61aeb79593e81c88f512a891198f6/68747470733a2f2f706f7365722e707567782e6f72672f6b6c65696a6e7765622f7068702d6170692d726f7574696e672d62756e646c652f762f756e737461626c65)](https://packagist.org/packages/kleijnweb/php-api-routing-bundle)[![Latest Stable Version](https://camo.githubusercontent.com/a3a635e3266ece796571b43d6612754ce2aae7e06923805efacc4b2795afb767/68747470733a2f2f706f7365722e707567782e6f72672f6b6c65696a6e7765622f7068702d6170692d726f7574696e672d62756e646c652f762f737461626c65)](https://packagist.org/packages/kleijnweb/php-api-routing-bundle)

 Install And Configure
--------------------------------------------------------

[](#-install-and-configure)

Install using composer (`composer require kleijnweb/php-api-routing-bundle`).

Add OpenApi (or RAML) routing to your app, for example:

```
test:
  resource: "path/to/spec.yml"
  type: php-api
```

The `type` as well as the `php-api` prefix mentioned below is configurable:

```
api_routing:
  name: customname
```

Routing
-------

[](#routing)

To view the routes added by PhpApi\\RoutingBundle, you can use Symfony's `debug:router`. Route keys include the API spec base filename to prevent collisions. For path parameters, PhpApiRoutingBundle adds additional requirements to the routes. This way `/foo/{bar}` and `/foo/bar` wont conflict when `bar` is defined to be an integer. This also supports Swaggers `pattern` and `enum` when dealing with string path parameters.

### Controller Resolution

[](#controller-resolution)

All controllers must be defined as services in the DI container. PhpApi\\RoutingBundle sees an `operation id` as composed from the following parts:

```
[router].[controller]:[method]

```

`Router` is a DI key namespace in this context. The `router` segment defaults to `php-api.controller`, but can be overwritten at the `Path Object` level using `x-router`:

```
paths:
  x-router: my.default.controller.di.namespace
  /foo:
    ...
  /foo/{bar}:
    ...
```

The `controller` segments defaults to the resource name as extracted from the path by convention. For example, for path `/foo/something` the default router + controller would be: `php-api.controller.foo`.

You can override the whole of `[router].[controller]` using `x-router-controller`. This will not only override the default, but any declaration of `x-router`, too:

```
paths:
  x-router: my.default.controller.di.namespace
  /foo:
    ...
  /foo/{bar}:
    x-router-controller: an.alternate.di.namespace.controller
    ...
```

The following is also supported (set controller for a specific method):

```
paths:
  x-router: my.default.controller.di.namespace
  /foo:
    ...
  /foo/{bar}:
    patch:
      x-router-controller: an.alternate.di.namespace.controller
    ...
```

Finally, the `method` segment defaults to the HTTP method name, but may be overridden using Swagger's `operationId` or `x-router-controller-method`. Note the Swagger spec requires `operationId` to be unique, so while `operationId` can contain only the method name, you're usually better off using `x-router-controller-method`. You can also use a fully qualified operation id using double colon notation, eg "my.controller.namespace.myresource:methodName". Combining `x-router` or `x-router-controller` and a qualified `operationId` ignores the former.

```
paths:
  x-router: my.default.controller.di.namespace
  /foo:
    ...
  /foo/{bar}:
    x-router-controller: an.alternate.di.namespace.controller
    post:
      # Ingores declarations above
      operationId: my.controller.namespace.myresource:methodName
    ...
```

```
paths:
  x-router: my.default.controller.di.namespace
  /foo:
    ...
  /foo/{bar}:
    post:
      # Resolves to 'my.default.controller.di.namespace.foo:methodName'
      x-router-controller-method: methodName
    ...
```

```
paths:
  /foo:
    ...
  /foo/{bar}:
    x-router-controller: an.alternate.di.namespace.controller
    post:
      # Same as above. Valid, but discouraged
      operationId: methodName
    ...
```

Contributing
------------

[](#contributing)

Pull request are *very* welcome, as long as:

- All automated checks were successful
- Merge would not violate semantic versioning
- When applicable, the relevant documentation is updated

License
-------

[](#license)

KleijnWeb\\PhpApi\\RoutingBundle is made available under the terms of the [LGPL, version 3.0](https://spdx.org/licenses/LGPL-3.0.html#licenseText).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

3326d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd6223a727c26ae6be208c1159924e9a2b43a9b11ae0da3afa1e641a49873fae?d=identicon)[kleijnweb](/maintainers/kleijnweb)

---

Top Contributors

[![johnknl](https://avatars.githubusercontent.com/u/8375560?v=4)](https://github.com/johnknl "johnknl (17 commits)")

---

Tags

swaggeropenapi

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kleijnweb-php-api-routing-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/kleijnweb-php-api-routing-bundle/health.svg)](https://phpackages.com/packages/kleijnweb-php-api-routing-bundle)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M373](/packages/easycorp-easyadmin-bundle)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k246.0M11.1k](/packages/symfony-framework-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M712](/packages/sylius-sylius)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M517](/packages/shopware-core)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19564.8M1.6k](/packages/drupal-core)

PHPackages © 2026

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