PHPackages                             tito10047/persistent-preference-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tito10047/persistent-preference-bundle

Abandoned → [https://github.com/tito10047/persistent-state-bundle](/?search=https%3A%2F%2Fgithub.com%2Ftito10047%2Fpersistent-state-bundle)Symfony-bundle[Utility &amp; Helpers](/categories/utility)

tito10047/persistent-preference-bundle
======================================

Easily manage persistent checkbox selections and key-value settings in Symfony applications.

0.1.3(2mo ago)20MITPHPPHP &gt;=8.2CI passing

Since Dec 4Pushed 2mo agoCompare

[ Source](https://github.com/tito10047/persistent-state-bundle)[ Packagist](https://packagist.org/packages/tito10047/persistent-preference-bundle)[ RSS](/packages/tito10047-persistent-preference-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (21)Versions (5)Used By (0)

[![Tests](https://github.com/tito10047/persistent-state-bundle/actions/workflows/symfony.yml/badge.svg)](https://github.com/tito10047/persistent-state-bundle/actions/workflows/symfony.yml/badge.svg)

Persistent State Bundle
=======================

[](#persistent-state-bundle)

[![](docs/image/promo_small.png)](docs/image/promo_small.png)

This Symfony bundle provides a unified and robust solution for managing persistent user interface state. It handles two key areas:

1. **Selections**: Efficient handling of bulk operations (e.g., "Select All" across multiple pages of a paginated list).
2. **Preferences**: Storing key-value settings for various contexts (e.g., user, company).

It features a flexible architecture based on context resolvers and support for various storage backends (Session, Redis, Doctrine), allowing you to elegantly solve UI state persistence without boilerplate code in your controllers.

Features
--------

[](#features)

- **Selection Management**: Track selected items (IDs) across pagination.
- **Preference Management**: Store and retrieve arbitrary user/context settings.
- **Context Resolvers**: Automatically resolve context (e.g., current user) for storage.
- **Twig Integration**: Easy-to-use Twig functions and filters.
- **Stimulus Integration**: Ready-to-use Stimulus controller for interactive selections.
- **Multiple Storages**: Support for Session (default), Doctrine, and easily extensible for others (e.g., Redis).
- **CLI Support**: Debug preferences directly from the terminal.

Requirements
------------

[](#requirements)

- **PHP**: ^8.1
- **Symfony**: ^6.4 | ^7.4 | ^8.0

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

[](#installation)

Install the bundle via Composer:

```
composer require tito10047/persistent-state-bundle
```

If you are using Symfony Flex, the bundle will be registered automatically. Otherwise, add it to your `config/bundles.php`:

```
return [
    // ...
    Tito10047\PersistentStateBundle\PersistentStateBundle::class => ['all' => true],
];
```

For Stimulus integration, ensure you have [Symfony UX Stimulus](https://symfony.com/bundles/StimulusBundle/current/index.html) installed and configured.

Usage Scenarios
---------------

[](#usage-scenarios)

### 1. Simple Selection (e.g., Shopping Cart)

[](#1-simple-selection-eg-shopping-cart)

```
use Tito10047\PersistentStateBundle\Selection\Service\SelectionManagerInterface;

class CartController
{
    public function __construct(
        private readonly SelectionManagerInterface $selectionManager,
    ) {}

    public function add(User $user, Product $product)
    {
        $cartSelection = $this->selectionManager->getSelection( 'cart',$user);
        $cartSelection->select($product, [
            'quantity' => 1,
            'added_at' => new \DateTime()
        ]);
    }

    public function clear(User $user)
    {
        $this->selectionManager->getSelection('cart',$user)->destroy();
    }
}
```

### 2. User Preferences

[](#2-user-preferences)

```
use Tito10047\PersistentStateBundle\Preference\Service\PreferenceManagerInterface;

class SettingsController
{
    public function __construct(
        private readonly PreferenceManagerInterface $prefManager,
    ) {}

    public function updateTheme(User $user, string $theme)
    {
        $preferences = $this->prefManager->getPreference($user);
        $preferences->set('theme', $theme);
    }
}
```

In Twig:

```

    Company Setting: {{ company|pref('some_setting') }}

```

### 3. Bulk Actions with Stimulus

[](#3-bulk-actions-with-stimulus)

This bundle provides a Stimulus controller to handle "Select All" and individual row selections.

```

            Select Visible

            Select All

        {% for log in logs %}

                {{ persistent_selection_row_selector("main_logs", log) }}
                {{ log.name }}

        {% endfor %}

```

In your controller to perform the action:

```
public function deleteSelected(User $user)
{
    $selection = $this->selectionManager->getSelection('main_logs', $user);
    $ids = $selection->getSelectedIdentifiers();

    // ... perform deletion
}
```

Configuration
-------------

[](#configuration)

Default configuration (optional to override in `config/packages/persistent_state.yaml`):

```
persistent_state:
    preference:
        managers:
            default:
                storage: '@persistent_state.preference.storage.session'
    selection:
        managers:
            default:
                storage: '@persistent_state.selection.storage.session'
```

See [docs/full\_config.md](docs/full_config.md) for more advanced configuration, including Doctrine storage setup.

Console Commands
----------------

[](#console-commands)

### `debug:preference`

[](#debugpreference)

Inspect stored preferences for a specific context.

```
php bin/console debug:preference "user_15" --manager=default
```

Testing
-------

[](#testing)

Run tests using PHPUnit:

```
composer test
```

License
-------

[](#license)

This bundle is released under the [MIT License](LICENSE).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance86

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

Total

4

Last Release

75d ago

PHP version history (2 changes)0.1.0PHP &gt;=8.1

0.1.3PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d6d558226302620ec462f64672e9dc81609227626923a808005641e76e8c38f?d=identicon)[tito10047](/maintainers/tito10047)

---

Top Contributors

[![tito10047](https://avatars.githubusercontent.com/u/11459248?v=4)](https://github.com/tito10047 "tito10047 (51 commits)")

---

Tags

checkboxkey-value-storepreferencessymfony-bundlesymfonyuisymfony-uxpaginationbatchpreference

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tito10047-persistent-preference-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tito10047-persistent-preference-bundle/health.svg)](https://phpackages.com/packages/tito10047-persistent-preference-bundle)
```

###  Alternatives

[babdev/pagerfanta-bundle

Bundle integrating Pagerfanta with Symfony

20917.8M65](/packages/babdev-pagerfanta-bundle)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

50570.7k1](/packages/web-auth-webauthn-framework)[spomky-labs/pwa-bundle

Progressive Web App Manifest Generator Bundle for Symfony.

6144.4k1](/packages/spomky-labs-pwa-bundle)[fsi/datagrid-bundle

FSi Datagrid Bundle

1859.8k1](/packages/fsi-datagrid-bundle)

PHPackages © 2026

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