PHPackages                             tangoman/callback-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. [Templating &amp; Views](/categories/templating)
4. /
5. tangoman/callback-bundle

ActiveLibrary[Templating &amp; Views](/categories/templating)

tangoman/callback-bundle
========================

Callback Symfony Twig Extension Bundle

2.2.0(7y ago)11671MITPHPPHP &gt;=5.5.0CI failing

Since Aug 18Pushed 10mo agoCompare

[ Source](https://github.com/TangoMan75/CallbackBundle)[ Packagist](https://packagist.org/packages/tangoman/callback-bundle)[ RSS](/packages/tangoman-callback-bundle/feed)WikiDiscussions main Synced 2mo ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (1)

[![GH language](https://camo.githubusercontent.com/85404bff3c1be0082bc3e600c952fb71764090ba2b1df445ff48821b844f3a45/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f54616e676f4d616e37352f43616c6c6261636b42756e646c65)](https://camo.githubusercontent.com/85404bff3c1be0082bc3e600c952fb71764090ba2b1df445ff48821b844f3a45/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f54616e676f4d616e37352f43616c6c6261636b42756e646c65)[![GH release](https://camo.githubusercontent.com/3ed172cf37a300f6ef2b64d184eb428ee379fb47c3b69c5f78231e463bfe8bdc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f54616e676f4d616e37352f43616c6c6261636b42756e646c65)](https://github.com/TangoMan75/CallbackBundle/releases)[![GH license](https://camo.githubusercontent.com/ea39719f979aed26d68b04a415f3e091700596eb3136fc296d20db9d69ce58ee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f54616e676f4d616e37352f43616c6c6261636b42756e646c65)](https://camo.githubusercontent.com/ea39719f979aed26d68b04a415f3e091700596eb3136fc296d20db9d69ce58ee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f54616e676f4d616e37352f43616c6c6261636b42756e646c65)[![GH stars](https://camo.githubusercontent.com/d3170d58c76851d83c4e5dd6ff53f9d5a4eaf0368f18f89481a817f3db616fa4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f54616e676f4d616e37352f43616c6c6261636b42756e646c65)](https://camo.githubusercontent.com/d3170d58c76851d83c4e5dd6ff53f9d5a4eaf0368f18f89481a817f3db616fa4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f54616e676f4d616e37352f43616c6c6261636b42756e646c65)[![PHP CI](https://github.com/TangoMan75/CallbackBundle/workflows/PHP%20CI/badge.svg)](https://github.com/TangoMan75/CallbackBundle/actions/workflows/php.yml)[![Visitors](https://camo.githubusercontent.com/6f698d44ec43df407f151a4cb1215a6a1f91db9d50dcb25c21b854d870aa353d/68747470733a2f2f6170692e76697369746f7262616467652e696f2f6170692f76697369746f72733f706174683d68747470732533412532462532466769746875622e636f6d25324654616e676f4d616e373525324643616c6c6261636b42756e646c65266c6162656c436f6c6f723d25323336393736383926636f756e74436f6c6f723d253233333764363761267374796c653d666c6174)](https://camo.githubusercontent.com/6f698d44ec43df407f151a4cb1215a6a1f91db9d50dcb25c21b854d870aa353d/68747470733a2f2f6170692e76697369746f7262616467652e696f2f6170692f76697369746f72733f706174683d68747470732533412532462532466769746875622e636f6d25324654616e676f4d616e373525324643616c6c6261636b42756e646c65266c6162656c436f6c6f723d25323336393736383926636f756e74436f6c6f723d253233333764363761267374796c653d666c6174)

TangoMan Callback Twig Extension Bundle
=======================================

[](#tangoman-callback-twig-extension-bundle)

**TangoMan Callback Twig Extension Bundle** provides simple callback function for twig which avoids unnecessary callbacks to stack up indefinitely in users query string.

🧩 Purpose of the `Callback` Class
---------------------------------

[](#-purpose-of-the-callback-class)

This class defines a Twig extension that introduces a custom function called `callback`. Its main job is to **generate clean URLs** by **removing `callback` parameters from query strings**, which can help avoid issues where multiple callbacks get appended indefinitely and make sure users query parameters are not lost in the process.

🔧 `callbackFunction()`
----------------------

[](#-callbackfunction)

```
public function callbackFunction($route = null, $parameters = [])
```

- **Behavior**:
    - If no route is provided -&gt; use the current request URI.
    - If a route is specified -&gt; generate a full URL using Symfony's router.
- **Core logic**:
    - Parses the URL.
    - Removes the `callback` parameter from the query string.
    - Reconstructs and returns the cleaned URL.

✨ Real-Life Use Case
--------------------

[](#-real-life-use-case)

Imagine you're building a redirect system where callbacks are passed through URLs. If multiple redirects occur (e.g., login flow, third-party auth, or form submissions), you might get URLs like this:

```
https://example.com/page?callback=https://another.com?callback=...

```

This class avoids that endless loop by **stripping the `callback`** query parameter from the final URL so it stays nice and tidy.

📦 Installation
==============

[](#-installation)

Step 1: Download the Bundle
---------------------------

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
composer require tangoman/callback-bundle
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

Step 2: Enable the Bundle
-------------------------

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `app/AppKernel.php` file of your project:

```
