PHPackages                             bornfight/jsonapi-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. bornfight/jsonapi-bundle

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

bornfight/jsonapi-bundle
========================

The jsonapi-bundle is a Symfony bundle. it is the fastest way to generate API based on JsonApi.org using woohoolabs/yin

v2.2.2(6y ago)0981MITPHPPHP ^7.1

Since Sep 9Pushed 6y ago7 watchersCompare

[ Source](https://github.com/degordian/jsonapi-bundle)[ Packagist](https://packagist.org/packages/bornfight/jsonapi-bundle)[ RSS](/packages/bornfight-jsonapi-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (15)Versions (19)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/8cf41783278235a028f2f3cdbee5c35ed09ed8b6507bdeaeca186d24eaade884/68747470733a2f2f706f7365722e707567782e6f72672f70616b6e616861642f6a736f6e6170692d62756e646c652f76657273696f6e)](https://packagist.org/packages/paknahad/jsonapi-bundle)[![Build Status](https://camo.githubusercontent.com/44a431d2866146729a1c3b8f9fdce2e0720fa98508b98960055a26f47a4e13fb/68747470733a2f2f7472617669732d63692e6f72672f70616b6e616861642f6a736f6e6170692d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/paknahad/jsonapi-bundle)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://choosealicense.com/licenses/mit/)[![Total Downloads](https://camo.githubusercontent.com/fd7681987547001f6af1c2af29c2172c7ae37a62d35bf313caf706d0e8d7469b/68747470733a2f2f706f7365722e707567782e6f72672f70616b6e616861642f6a736f6e6170692d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/paknahad/jsonapi-bundle)

JsonApiBundle For Symfony
=========================

[](#jsonapibundle-for-symfony)

JsonApiBundle is a [Symfony](https://symfony.com/) bundle. It is the fastest way to generate API based on [JsonApi](http://jsonapi.org/)using [woohoolabs/yin](https://github.com/woohoolabs/yin) Library.

Installing
----------

[](#installing)

1. Install symfony

    ```
    composer create-project symfony/skeleton YOUR_PROJECT

    ```
2. Install the [maker bundle](https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html)

    ```
    composer require symfony/maker-bundle phootwork/collection --dev

    ```
3. Install the bundle

    ```
    composer require paknahad/jsonapi-bundle

    ```
4. Add below line to `config/bundles.php`

    ```
    Paknahad\JsonApiBundle\JsonApiBundle::class => ['all' => true],

    ```

Usage
-----

[](#usage)

1. Use below command to generate entities one by one:

    ```
    bin/console make:entity

    ```

    for example, Book and Author entity is as follows:

    ```
    class Book
    {
        /**
         * @ORM\Id()
         * @ORM\GeneratedValue()
         * @ORM\Column(type="integer")
         */
        private $id;

        /**
         * @ORM\Column(type="string", length=255)
         */
        private $title;

        /**
         * @ORM\Column(type="string", length=20, nullable=true)
         */
        private $isbn;

        /**
         * @ORM\ManyToMany(targetEntity="App\Entity\Author", inversedBy="books")
         */
        private $authors;

        ...
    ```

    ```
    class Author
    {
        /**
         * @ORM\Id()
         * @ORM\GeneratedValue()
         * @ORM\Column(type="integer")
         */
        private $id;

        /**
         * @ORM\Column(type="string", length=255)
         * @Assert\NotBlank()
         * @Assert\Length(min=3)
         */
        private $name;

        /**
         * @ORM\ManyToMany(targetEntity="App\Entity\Book", mappedBy="authors")
         */
        private $books;

        ...
    ```
2. Generate CRUD API:

    ```
    bin/console make:api

    ```
3. You can find the generated "collections" for [postman](https://www.getpostman.com/) and [swagger](https://swagger.io/) in the following path and then test the API:

    ```
    collection/postman.json
    collection/swagger.yaml

    ```

Features
--------

[](#features)

### Pagination

[](#pagination)

```
http://example.com/books?page[number]=5&page[size]=30

```

### Sorting

[](#sorting)

- Ascending on name field: `http://example.com/books?sort=name`
- Decending on name field: `http://example.com/books?sort=-name`
- Multiple fields: `http://example.com/books?sort=city,-name`
- Field on a relation: `http://example.com/books?sort=author.name`

### Relationships

[](#relationships)

```
http://example.com/books?include=authors

```

multiple relationships

```
http://example.com/books?include=authors.phones,publishers

```

### Search

[](#search)

As the [JSON API specification](http://jsonapi.org/) does not [specify exactly how filtering should work](http://jsonapi.org/recommendations/#filtering) different methods of filtering can be used. Each method is supplied with a Finder service. Each registered Finder will be able to append conditions to the search query. If you register multiple Finders they are all active at the same time. This enables your API to support multiple filtering methods.

#### Basic Finder.

[](#basic-finder)

A basic Finder is included in this library offering simple filtering capabilities:

This request will return all the books that author's name begin with `hamid`

```
http://example.com/books?filter[authors.name]=hamid%

```

Below line has additional condition: books which have "php" in their title.

```
http://example.com/books?filter[title]=%php%&filter[authors.name]=hamid%

```

#### Other Finders

[](#other-finders)

Currently the following Finders are available via other bundles:

- [mnugter/jsonapi-rql-finder-bundle](https://github.com/mnugter/jsonapi-rql-finder-bundle) - [RQL](https://github.com/persvr/rql) based Finder
- [paknahad-jsonapi-querifier-bundle](https://github.com/paknahad/jsonapi-querifier-bundle) - [Querifier](https://github.com/paknahad/querifier) based Finder

#### Creating a custom Finder

[](#creating-a-custom-finder)

A Finder can be registered via a service tag in the services definition. The tag `paknahad.json_api.finder` must be added to the service for the Finder to be resigered.

Example:

```

```

Each Finder must implement the `Paknahad\JsonApiBundle\Helper\Filter\FinderInterface` interface.

### Validation

[](#validation)

Error on validating associations

```
{
    "jsonapi": {
        "version": "1.0"
    },
    "errors": [
        {
            "detail": "Invalid value for this relation",
            "source": {
                "pointer": "/data/relationships/authors",
                "parameter": "1"
            }
        }
    ]
}
```

Validate attributes if you have defined validators on entities.

```
{
    "jsonapi": {
        "version": "1.0"
    },
    "errors": [
        {
            "detail": "This value is too short. It should have 3 characters or more.",
            "source": {
                "pointer": "/data/attributes/name",
                "parameter": "h"
            }
        }
    ]
}
```

### Error handler

[](#error-handler)

All errors such as:

- Internal server error (500)
- Not found (404)
- Access denied (403)

has responses like this:

```
{
    "meta": {
        "code": 0,
        "message": "No route found for \"GET /book\"",
        "file": "/var/www/vendor/symfony/http-kernel/EventListener/RouterListener.php",
        "line": 139,
        "trace": [
            {
                "file": "/var/www/vendor/symfony/event-dispatcher/EventDispatcher.php",
                "line": 212,
                "function": "onKernelRequest"
            },
            {
                "file": "/var/www/vendor/symfony/event-dispatcher/EventDispatcher.php",
                "line": 44,
                "function": "doDispatch"
            },
            {
                "file": "/var/www/vendor/symfony/http-kernel/HttpKernel.php",
                "line": 125,
                "function": "dispatch"
            },
            {
                "file": "/var/www/vendor/symfony/http-kernel/HttpKernel.php",
                "line": 66,
                "function": "handleRaw"
            },
            {
                "file": "/var/www/vendor/symfony/http-kernel/Kernel.php",
                "line": 188,
                "function": "handle"
            },
            {
                "file": "/var/www/public/index.php",
                "line": 37,
                "function": "handle"
            }
        ]
    },
    "links": {
        "self": "/book"
    },
    "errors": [
        {
            "status": "404",
            "code": "NO_ROUTE_FOUND_FOR_\"GET_/BOOK\"",
            "title": "No route found for \"GET /book\""
        }
    ]
}
```

NOTICE: the "meta" field gets filled just on development environment.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 84.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 ~20 days

Total

16

Last Release

2502d ago

Major Versions

v1.2.2 → v2.0.0-alpha2018-10-24

1.2.x-dev → v2.0.02019-01-05

PHP version history (2 changes)v1.0.0PHP ^7.2

v1.2.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/17c53fee05473b5d0c8b576d19b085f89765dbe7beb565e6a67cf2f8591d481b?d=identicon)[Bornfight](/maintainers/Bornfight)

---

Top Contributors

[![paknahad](https://avatars.githubusercontent.com/u/1970573?v=4)](https://github.com/paknahad "paknahad (55 commits)")[![dvorsky](https://avatars.githubusercontent.com/u/9594939?v=4)](https://github.com/dvorsky "dvorsky (5 commits)")[![mnugter](https://avatars.githubusercontent.com/u/1712411?v=4)](https://github.com/mnugter "mnugter (2 commits)")[![brunozoric](https://avatars.githubusercontent.com/u/10399339?v=4)](https://github.com/brunozoric "brunozoric (1 commits)")[![Krilo89](https://avatars.githubusercontent.com/u/5180445?v=4)](https://github.com/Krilo89 "Krilo89 (1 commits)")[![taccommandeur](https://avatars.githubusercontent.com/u/34679042?v=4)](https://github.com/taccommandeur "taccommandeur (1 commits)")

---

Tags

phpsymfonygeneratorcode generatorrestfulJSON-API

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/bornfight-jsonapi-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/bornfight-jsonapi-bundle/health.svg)](https://phpackages.com/packages/bornfight-jsonapi-bundle)
```

###  Alternatives

[paknahad/jsonapi-bundle

The jsonapi-bundle is a Symfony bundle. it is the fastest way to generate API based on JsonApi.org using woohoolabs/yin

7155.8k4](/packages/paknahad-jsonapi-bundle)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[openai-php/symfony

Symfony Bundle for OpenAI

215715.5k3](/packages/openai-php-symfony)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)

PHPackages © 2026

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