Download the PHP package ecourty/platform-parameter-bundle without Composer

On this page you can find all versions of the php package ecourty/platform-parameter-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package platform-parameter-bundle

Platform Parameter Bundle

CI

A Symfony bundle for managing global platform parameters with type-safe access and caching.
Supports PHP 8.3+, Symfony 7.x and 8.x.

Table of Contents

Features

Installation

Optional: EasyAdmin Integration

If your project uses EasyAdmin, the bundle includes a ready-to-use CRUD controller:

Register the bundle

If you're not using Symfony Flex, add the bundle to config/bundles.php:

Important: The bundle automatically configures Doctrine ORM mappings for the entity class specified in your configuration. No manual Doctrine mapping configuration is required - just configure entity_class in your bundle settings, and the mapping is handled automatically.

Configuration

Create a configuration file config/packages/platform_parameter.yaml:

Cache Adapter Resolution

The bundle automatically creates a TagAware cache pool (platform_parameter.cache) for optimal performance out-of-the-box.

Cache adapter priority:

  1. Custom adapter (if cache_adapter is specified in config)
  2. Auto-created TagAware pool (platform_parameter.cache - created by default)
  3. Default (cache.app as ultimate fallback)

No configuration needed! The bundle works optimally by default with TagAware support.

Example - Using a custom Redis cache pool:

Example - Overriding the default pool:

Database Setup

Run Doctrine migrations to create the platform_parameter table:

Note: This works seamlessly with custom entities extending AbstractPlatformParameter. Doctrine will automatically detect all fields (base + custom) when generating migrations.

Configuration Reference

All available configuration options with their default values:

Configuration Options Details

Option Type Default Description
entity_class string Ecourty\PlatformParameterBundle\Entity\PlatformParameter FQCN of the entity class. Must extend AbstractPlatformParameter. Allows you to use a custom entity with additional fields.
cache_ttl int 3600 Cache TTL in seconds. Controls how long parameters are cached. Set to 0 to disable TTL (cache until manually cleared).
cache_key_prefix string platform_parameter Prefix for all cache keys. Useful if you have multiple parameter systems or want to avoid key collisions.
clear_cache_on_parameter_update bool true When enabled, automatically clears parameter cache on entity changes (create/update/delete) via a Doctrine listener. Disable if you prefer manual cache management.
cache_adapter string\|null null Service ID of a custom cache adapter. If null, the bundle automatically uses platform_parameter.cache (auto-created TagAware pool) or falls back to cache.app.

Usage

Basic Usage

Inject the PlatformParameterProviderInterface into your services:

Available Methods

DateTime Format Support

The getDateTime() method automatically tries these formats:

Or specify a custom format:

Cache Management

The bundle automatically caches all parameters to minimize database queries. When you access a parameter (e.g., getString('site_name')), it's fetched from the database once and cached for subsequent requests. This significantly reduces database load, especially for frequently accessed parameters. The cache TTL is configurable (default: 3600 seconds / 1 hour).

Automatic Cache Clearing (Default Behavior)

By default, the bundle automatically clears the cache when you create, update, or delete a parameter using a Doctrine entity listener:

This is enabled by default via the clear_cache_on_parameter_update: true configuration option. The bundle uses a Doctrine listener that automatically wipes the cache for the parameter whenever the entity is persisted, updated, or removed.

Reacting to Parameter Changes with Events

The bundle dispatches Symfony events whenever parameters are created, updated, or deleted. This provides a simple way to react to parameter changes without configuring Doctrine listeners.

Available Events:

Example: Send notifications when parameters change

Event Details:

Events are always dispatched, regardless of the clear_cache_on_parameter_update configuration. They work with:

To disable automatic cache clearing (but keep event dispatching):

Note: Disabling cache clearing means you'll need to manually call $parameterProvider->clearCache() or handle cache invalidation via event subscribers.

Manual Cache Clearing

You can still manually clear the cache when needed:

Note: When clearing all caches, the bundle:

  1. If using TagAwareAdapter: Uses tags for efficient invalidation
  2. Otherwise: Fetches all parameters from DB and deletes their cache items individually

Optimizing Cache Performance

The bundle automatically creates a TagAware cache pool for optimal performance. No additional configuration is needed!

Benefits:

Advanced - Using Redis for better performance:

The bundle will automatically use your custom platform_parameter.cache pool if defined.

Parameter Types

The bundle supports 7 parameter types:

Type Description Example
STRING Simple text value "Hello World"
INTEGER Numeric integer 42
BOOLEAN Boolean value "true", "1", "yes"
JSON JSON object/array {"key": "value"}
LIST Multi-line or separated list "line1\nline2" or "a,b,c"
FLOAT Decimal number 19.99, -15.5, 1.5e-3
DATETIME Date/time value 2026-01-21, 2026-01-21 15:30:00

Updating Parameters

The bundle provides a PlatformParameterWriter service for updating parameter values from your code with type safety:

Writer Methods:

Important Notes:

Why no auto-creation? If you use a custom entity extending AbstractPlatformParameter with additional required fields (category, icon, etc.), the Writer doesn't know how to populate them. Parameter creation must be explicit.

Creating Parameters

Parameters must be created using Doctrine entities directly:

This is the only way to create parameters. It ensures:

Error Handling

If a parameter doesn't exist and no default value is provided, a ParameterNotFoundException is thrown:

CLI Commands

The bundle provides convenient console commands to manage parameters:

List all parameters

Displays a table with all parameters showing their key, value (truncated if too long), type, and label.

View a specific parameter

Shows all metadata for a parameter including ID, key, value, type, label, description, and timestamps.

Update a parameter value

Behavior:

Note: This command only updates existing parameters. To create new parameters, use Doctrine entities directly (see "Creating Parameters" section).

Delete a parameter

Asks for confirmation before deletion (unless --force is used).

Clear parameter cache

Manually clears the cache for one or all parameters. Useful if automatic cache clearing is disabled.

EasyAdmin CRUD Interface

If you have EasyAdmin installed, you can use the included CRUD controller to manage parameters.

Register the controller in your EasyAdmin dashboard:

The CRUD controller includes:

Optional - Customizing the Controller:

If you need to customize the controller behavior (e.g., change titles, add custom fields, modify permissions), you can extend it:

Then reference your custom controller in the dashboard instead:

Twig Integration

If Twig is installed in your project, the bundle automatically registers a Twig extension providing functions to read parameters directly in templates. No additional configuration is needed.

Available Twig functions:

Function Return type
platform_parameter_string(key, default) string\|null
platform_parameter_int(key, default) int\|null
platform_parameter_bool(key, default) bool\|null
platform_parameter_float(key, default) float\|null
platform_parameter_json(key, default) array\|null
platform_parameter_list(key, default, separator) array\|null
platform_parameter_datetime(key, default, format) DateTimeImmutable\|null

All functions return null (instead of throwing an exception) when the parameter is not found and no default is provided.

Examples:

Extending the Entity

The bundle is designed to be extensible. You can create your own entity that extends the base AbstractPlatformParameter to add custom fields.

Step 1: Create Your Custom Entity

Step 2: Configure the Bundle

Update your platform_parameter.yaml configuration:

Step 3: Update Database Schema

Step 4: (Optional) Create Custom EasyAdmin CRUD Controller

If you added custom fields and want them in EasyAdmin:

Benefits of Extending

Development

Running Tests

Code Quality

License

MIT License - see LICENSE file for details.


All versions of platform-parameter-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
doctrine/doctrine-bundle Version ^2.18|^3.1
doctrine/orm Version ^3.0|^4.0
psr/cache Version ^2.0|^3.0
symfony/cache Version ^7.0|^8.0
symfony/config Version ^7.0|^8.0
symfony/dependency-injection Version ^7.0|^8.0
symfony/http-kernel Version ^7.0|^8.0
symfony/uid Version ^7.0|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ecourty/platform-parameter-bundle contains the following files

Loading the files please wait ...