PHPackages                             eltharin/ajaxresponser - 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. eltharin/ajaxresponser

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

eltharin/ajaxresponser
======================

AjaxResponser Bundle for symfony

V1.6.1(1y ago)179GPL-3.0PHP

Since Feb 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/eltharin/ajaxresponser)[ Packagist](https://packagist.org/packages/eltharin/ajaxresponser)[ RSS](/packages/eltharin-ajaxresponser/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (7)Used By (0)

Symfony AjaxResponser Bundle
============================

[](#symfony-ajaxresponser-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/067170d4ee0cc3cf6b5b1f09b4ac7d7431fad10d5c05a91332d94b565df59054/687474703a2f2f706f7365722e707567782e6f72672f656c74686172696e2f616a6178726573706f6e7365722f76)](https://packagist.org/packages/eltharin/ajaxresponser)[![Total Downloads](https://camo.githubusercontent.com/88b35e39df1ff240417eddb03dd74378a6f0c40a1bee8f6bf01c82723d09f3db/687474703a2f2f706f7365722e707567782e6f72672f656c74686172696e2f616a6178726573706f6e7365722f646f776e6c6f616473)](https://packagist.org/packages/eltharin/ajaxresponser)[![Latest Unstable Version](https://camo.githubusercontent.com/a8dc21a7460b3d1cb605d8838a1f5c39d482436ba29d613bc33319d3838f9435/687474703a2f2f706f7365722e707567782e6f72672f656c74686172696e2f616a6178726573706f6e7365722f762f756e737461626c65)](https://packagist.org/packages/eltharin/ajaxresponser)[![License](https://camo.githubusercontent.com/1aa1e35db295ad360d8ab6b0b5415171b3051c3fc82bb975f63cf86d9860b9bf/687474703a2f2f706f7365722e707567782e6f72672f656c74686172696e2f616a6178726573706f6e7365722f6c6963656e7365)](https://packagist.org/packages/eltharin/ajaxresponser)

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

[](#installation)

- Require the bundle with composer:

```
composer require eltharin/ajaxresponser
```

What is AjaxResponser Bundle?

AjaxResponser is a bundle whitch allow to have routes responding with HTML or Json depending the request.

eg: a delete request in HTML will respond HTML page (or redirect) with a flash message, but the same page call by ajax, will respond a Json with the result and the flash message.

Use It :
--------

[](#use-it-)

Just Add AjaxOrNot Attribute to your route :

```
use Eltharin\AjaxResponserBundle\Annotations\AjaxCallOrNot;

...

#[Route(path: '/test-ajax-responser', name: 'app_test_ajax_responser')]
#[AjaxCallOrNot]
public function test_ajax_responser(): Response
{
    //-- Actions

    $this->addFlash('success', 'all is good');

    return $this->redirectToRoute('app_home');
}
```

If you go to /test-ajax-responser you will be redirect to your homepage with a flash message all is good

But if your call the same page in AJAX, with a header X-Requested-With with value XMLHttpRequest,

you got a Json Response :

```
{
    "statusCode": 302,
    "content": "\n\n    \n        \n        Hello HomeController!\n        \n                \n                    \n    \n    \n        Flash Messages\n\n            \n        \n    .example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px\/1.5 sans-serif; }\n    .example-wrapper code { background: #F5F5F5; padding: 2px 6px; }\n\n\n\n    Hello HomeController! \u2705\n\n    This friendly message is coming from:\n    \n        Your controller at src\/Controller\/HomeController.php\n        Your template at templates\/home\/index.html.twig\n    \n\n\n    \n        window.addEventListener(\"DOMContentLoaded\", (event) => {\n            Flashes.init('.messageContainer');\n        });\n    \n    \n\n",
    "msgs": {
        "success": [
            "all is good"
       ]
    },
    "redirectUrl": "\/home"
}
```

you get :

- statusCode : the original HTTP return code here 302 for the redirect
- content : content returned after the redirect
- msgs : flashes messages
- redirectUrl : Url who generated the content

Get the content after redirect can offer you to don't make an other ajax for actualize actual page,

eg: you have a page showing many items, you want to delete one with a delete button, the route make the delete action and redirect you to the item page, so you have the HTML and can replace directly.

You can disable getting this content by set the getRedirectContent param to false :

```
use Eltharin\AjaxResponserBundle\Annotations\AjaxCallOrNot;

...

#[Route(path: '/test-ajax-responser', name: 'app_test_ajax_responser')]
#[AjaxCallOrNot(getRedirectContent: false)]
public function test_ajax_responser(): Response
{
    //-- Actions

    $this->addFlash('success', 'all is good');

    return $this->redirectToRoute('app_home');
}
```

now you have the redirect HTML.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance46

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Recently: every ~106 days

Total

6

Last Release

409d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7547802?v=4)[eltharin](/maintainers/eltharin)[@eltharin](https://github.com/eltharin)

---

Top Contributors

[![eltharin](https://avatars.githubusercontent.com/u/7547802?v=4)](https://github.com/eltharin "eltharin (13 commits)")

---

Tags

symfonybundlewebcssJS

### Embed Badge

![Health badge](/badges/eltharin-ajaxresponser/health.svg)

```
[![Health](https://phpackages.com/badges/eltharin-ajaxresponser/health.svg)](https://phpackages.com/packages/eltharin-ajaxresponser)
```

###  Alternatives

[stfalcon-studio/api-bundle

Base classes and helper services to build API application via Symfony.

1034.6k](/packages/stfalcon-studio-api-bundle)

PHPackages © 2026

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