Download the PHP package tito10047/persistent-preference-bundle without Composer
On this page you can find all versions of the php package tito10047/persistent-preference-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tito10047/persistent-preference-bundle
More information about tito10047/persistent-preference-bundle
Files in tito10047/persistent-preference-bundle
Package persistent-preference-bundle
Short Description Easily manage persistent checkbox selections and key-value settings in Symfony applications.
License MIT
Informations about the package persistent-preference-bundle
Persistent State Bundle
This Symfony bundle provides a unified and robust solution for managing persistent user interface state. It handles two key areas:
- Selections: Efficient handling of bulk operations (e.g., "Select All" across multiple pages of a paginated list).
- 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
- 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
- PHP: ^8.1
- Symfony: ^6.4 | ^7.4 | ^8.0
Installation
Install the bundle via Composer:
If you are using Symfony Flex, the bundle will be registered automatically. Otherwise, add it to your config/bundles.php:
For Stimulus integration, ensure you have Symfony UX Stimulus installed and configured.
Usage Scenarios
1. Simple Selection (e.g., Shopping Cart)
2. User Preferences
In Twig:
3. Bulk Actions with Stimulus
This bundle provides a Stimulus controller to handle "Select All" and individual row selections.
In your controller to perform the action:
Configuration
Default configuration (optional to override in config/packages/persistent_state.yaml):
See docs/full_config.md for more advanced configuration, including Doctrine storage setup.
Console Commands
debug:preference
Inspect stored preferences for a specific context.
Testing
Run tests using PHPUnit:
License
This bundle is released under the MIT License.
All versions of persistent-preference-bundle with dependencies
symfony/framework-bundle Version ^6.4|^7.4|^8.0
symfony/property-access Version ^6.4|^7.4|^8.0