PHPackages                             redrat/api-helper-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. redrat/api-helper-bundle

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

redrat/api-helper-bundle
========================

0.2.1(5y ago)3631MITPHPPHP &gt;=7.4

Since Jun 28Pushed 5y agoCompare

[ Source](https://github.com/joubertredrat/ApiHelperBundle)[ Packagist](https://packagist.org/packages/redrat/api-helper-bundle)[ Docs](https://github.com/joubertredrat/ApiHelperBundle)[ RSS](/packages/redrat-api-helper-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

Api Helper Bundle
=================

[](#api-helper-bundle)

[![Build Status](https://camo.githubusercontent.com/15d9e486a457a13fad277e190d9ba8130a510c4dd24529a885603d2950315e3a/68747470733a2f2f7472617669732d63692e6f72672f6a6f75626572747265647261742f41706948656c70657242756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/joubertredrat/ApiHelperBundle)[![Maintainability](https://camo.githubusercontent.com/b4af8028131244e642acaf0113ba7f97328e8b304797078be92a89aa1ba649d0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f62343561376562616632396537393365613931382f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/joubertredrat/ApiHelperBundle/maintainability)[![Test Coverage](https://camo.githubusercontent.com/d2f0cccc24caf06c3c8cac63b1a70902c5575bf369a0309a515e7103ae1dc10a/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f62343561376562616632396537393365613931382f746573745f636f766572616765)](https://codeclimate.com/github/joubertredrat/ApiHelperBundle/test_coverage)[![Latest Stable Version](https://camo.githubusercontent.com/edb0bbda02e161948ef61c328a86842f8345243152583f542b2eeb97bb2de515/68747470733a2f2f706f7365722e707567782e6f72672f7265647261742f6170692d68656c7065722d62756e646c652f76)](https://packagist.org/packages/redrat/api-helper-bundle)[![Total Downloads](https://camo.githubusercontent.com/31f78014a58af21ce8a35bc98bade4e11848e9e14688548fddb212cd637cb2ed/68747470733a2f2f706f7365722e707567782e6f72672f7265647261742f6170692d68656c7065722d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/redrat/api-helper-bundle/stats)[![License](https://camo.githubusercontent.com/645888b1d7fa5e932c20f94a12dda295c9fd3253d3753a3845baeeeebc69e8c6/68747470733a2f2f706f7365722e707567782e6f72672f7265647261742f6170692d68656c7065722d62756e646c652f6c6963656e7365)](https://packagist.org/packages/redrat/api-helper-bundle)[![FOSSA Status](https://camo.githubusercontent.com/b2d78be9562f9ec3e0e394bb53dad3cfab6ca1b6410d8b85161605e42dcb4aa5/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532466a6f756265727472656472617425324641706948656c70657242756e646c652e7376673f747970653d736869656c64)](https://app.fossa.com/projects/git%2Bgithub.com%2Fjoubertredrat%2FApiHelperBundle?ref=badge_shield)

This Symfony bundle provides configuration to validate and convert data for API routes.

#### First question, why?

[](#first-question-why)

Because I needed a bundle with configurable url prefix to use as API routes. For default in Symfony, only requests with content type `multipart/form-data` and `application/x-www-form-urlencoded` will have Request class with parameters data easily accessible by `get()` method, as example below.

```
class MyController
{
    public function handleForm(Request $request): Response
    {
        $myName = $request->get('myName'); // return Joubert RedRat
    }

    public function handleApi(Request $request): Response
    {
        $myName = $request->get('myName'); // return null
    }
}
```

With this bundle will be possible to configure which routes will work as API routes and any request with content type `application/json` will have Request class with parameters data easily accessible too.

#### Okay, how to install then?

[](#okay-how-to-install-then)

Easy my friend, install with the composer.

```
composer require redrat/api-helper-bundle
```

#### Configure the bundle (if necessary)

[](#configure-the-bundle-if-necessary)

If your composer don't like Symfony recipes contrib, don't worry, you can configure too.

- Open `config/bundles.php` and add the bundle like below.

```
return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    RedRat\ApiHelperBundle\ApiHelperBundle::class => ['all' => true],
];
```

- Create `config/packages/redrat_api_helper.yaml` and set initial config like below.

```
redrat_api_helper:
    paths:
```

#### How to bundle works?

[](#how-to-bundle-works)

This bundle works with a configuration defined in `config/packages/redrat_api_helper.yaml`. Into this file you will config which url path prefix will work as API url, like example below:

```
redrat_api_helper:
    paths:
        my_amazing_api_v1:
            url_path_prefix: /api/v1
        other_api_v3:
            url_path_prefix: /api/v3
        old_not_cute_api:
            url_path_prefix: /legacy/api
```

You can configure one or more url path prefixes as you need.

After this, all url path that matches with a configuration will be acted by the bundle and will be validated and data putted into request class.

Look that only routes that matches will be acted by the bundle, like example below using configuration above.

```
GET /api/v1/accounts/users => matches
POST /api/login => doesn't matches
DELETE /api/v2/emails => doesn't matches
PUT /api/v1/accounts/users/46 => matches
PATCH /api/v1/accounts/users => matches
GET /about-us => doesn't matches
GET /legacy/api/v1/cities => matches

```

### Validations

[](#validations)

This bundle performs 2 validations in a route matched with configuration.

##### Content-type

[](#content-type)

Route matched should have `application/json` as Content-Type with methods `POST`, `PUT` and `PATCH`. If not pass by this validation, bundle will return error below. Methods `GET` and `DELETE` normally don't contain body data, then these methods isn't validated.

```
< HTTP/2 400

{
  "error": "Invalid Content-Type, expected application\/json, got application\/x-www-form-urlencoded"
}

```

##### Valid json data

[](#valid-json-data)

Route matched should have valid [RFC7159](http://www.faqs.org/rfcs/rfc7159.html) json data in body. If not pass by this validation, bundle will return error below.

```
< HTTP/2 400

{
  "error": "Invalid json body data"
}

```

### Author

[](#author)

[Me](https://github.com/joubertredrat) and the [contributors](https://github.com/joubertredrat/ApiHelperBundle/graphs/contributors).

### License

[](#license)

The cute and amazing [MIT](https://github.com/joubertredrat/ApiHelperBundle/blob/master/LICENSE).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Total

3

Last Release

2140d ago

### Community

Maintainers

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

---

Top Contributors

[![joubertredrat](https://avatars.githubusercontent.com/u/1520407?v=4)](https://github.com/joubertredrat "joubertredrat (20 commits)")

---

Tags

api-jsonapi-restjson-apiphpsymfonysymfony-bundlesymfony4symfony5

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/redrat-api-helper-bundle/health.svg)

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[happyr/google-api-bundle

A Symfony2 Wrapper for the Google APIs Client Library for PHP

48196.1k](/packages/happyr-google-api-bundle)

PHPackages © 2026

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