adolfoholzer / parameters
A dynamic parameter management package for Laravel that provides a simple and flexible way to define, store, and retrieve typed configuration values.
Fund package maintenance!
Requires
- php: ^8.3
- illuminate/support: ^12.0||^13.0
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pao: ^1.0
- laravel/pint: ^1.29
- orchestra/testbench: ^10.0||^11.0
- pestphp/pest: ^4.6||^5.0
- pestphp/pest-plugin-laravel: ^4.1||^5.0
- pestphp/pest-plugin-type-coverage: ^4.0||^5.0
- phpstan/extension-installer: ^1.4
This package is not auto-updated.
Last update: 2026-08-14 23:37:23 UTC
README
Parameters
A dynamic parameter management package for Laravel that provides a simple and flexible way to define, store, and retrieve typed configuration values.
Installation
You can install the package via Composer:
composer require adolfoholzer/parameters
You may publish all of the package's resources at once:
php artisan vendor:publish --tag="parameters"
Or, you may publish each resource individually:
Publishing the Configuration File
php artisan vendor:publish --tag="parameters-config"
Publishing and Running the Migrations
php artisan vendor:publish --tag="parameters-migrations"
php artisan migrate
Usage
Basic Usage
The package supports two types of parameters:
- Global system parameters
- Parameters associated with specific models
All values are stored with an explicit type and automatically cast back to their corresponding native type when retrieved.
Global Parameters
Use the Parameters Facade to manage global configuration:
use Parameters; use Zitro\Parameters\Enums\ParameterType;
Storing Parameters
Parameters::set( 'site_iva', 22.5, ParameterType::FLOAT, 'General sales tax rate' ); Parameters::set( 'maintenance_mode', true, ParameterType::BOOLEAN ); Parameters::set( 'allowed_countries', ['UY', 'AR', 'BR'], ParameterType::JSON );
Retrieving Parameters
Values are automatically returned with their corresponding native type.
$iva = Parameters::get('site_iva'); // float(22.5) $maintenance = Parameters::get('maintenance_mode'); // bool(true) $countries = Parameters::get('allowed_countries'); // ['UY', 'AR', 'BR']
Default values
$logo = Parameters::get( 'site_logo', 'default-logo.png' );
Removing parameters
Parameters::forget('site_iva');
The associated cache entry will be automatically invalidated.
Model-Specific Parameters
You can store configuration values for any entity in your application.
For example:
- Users
- Teams
- Customers
- Projects
- Organizations
Preparing a Model
Add the HasParameters trait to your model:
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Zitro\Parameters\Traits\HasParameters; class Team extends Model { use HasParameters; }
Storing Parameters
use Zitro\Parameters\Enums\ParameterType; $team = Team::find($id); $team->setParameter( 'max_users', 15, ParameterType::INT, 'Maximum number of subscribed users' ); $team->setParameter( 'modules_enabled', ['crm', 'billing'], ParameterType::JSON );
Retrieving Parameters
$maxUsers = $team->getParameter('max_users'); // int(15) $modules = $team->getParameter('modules_enabled'); // ['crm', 'billing']
Removing Parameters
$team->forgetParameter('max_users');
Supported Types
The package provides native support for:
| Type | Returned Value |
|---|---|
| STRING | string |
| INT | int |
| FLOAT | float |
| BOOLEAN | bool |
| JSON | array |
Values are automatically cast using the type defined when the parameter is stored.
Caching
To minimize repeated database queries, the package includes a transparent caching layer.
Features:
- Independent caching for global parameters
- Segmented caching for polymorphic parameters
- Automatic cache invalidation when values are updated
- Configurable TTL
Configuration:
'use_cache' => true, 'cache_ttl' => 3600,
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Thank you for considering contributing to Parameters! Please review our contributing guide to get started.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
Parameters is open-sourced software licensed under the MIT license.