Skip to content

Configuration

Data Helpers works out of the box with zero configuration, but you can customize its behavior for your specific needs.

Data Helpers automatically registers its service provider in Laravel. No configuration is required.

You can publish the configuration file:

Terminal window
php artisan vendor:publish --tag=data-helpers-config

This creates config/data-helpers.php:

return [
'performance_mode' => env('DATA_HELPERS_PERFORMANCE_MODE', false),
'cache_enabled' => env('DATA_HELPERS_CACHE_ENABLED', true),
];

Data Helpers automatically registers its bundle in Symfony. No configuration is required.

Create config/packages/data_helpers.yaml:

data_helpers:
performance_mode: '%env(bool:DATA_HELPERS_PERFORMANCE_MODE)%'
cache_enabled: '%env(bool:DATA_HELPERS_CACHE_ENABLED)%'

For plain PHP projects, use the ConfigLoader to load and merge configuration:

use event4u\DataHelpers\Config\ConfigLoader;
use event4u\DataHelpers\DataHelpersConfig;
// Load config with deep merging
$config = ConfigLoader::load(__DIR__ . '/config/data-helpers.php');
DataHelpersConfig::initialize($config);

The ConfigLoader performs deep merging - you only need to specify values you want to change. All other values use package defaults.

See ConfigLoader for detailed documentation.

You can also configure Data Helpers programmatically:

use event4u\DataHelpers\DataHelpersConfig;
DataHelpersConfig::set('performance_mode', 'fast');
DataHelpersConfig::set('cache.max_entries', 1000);

Enable performance mode for production environments:

use event4u\DataHelpers\DataHelpersConfig;
DataHelpersConfig::set('performance_mode', 'fast');
// Options: 'fast' or 'safe'

This disables debug features and enables optimizations.

Configure caching:

use event4u\DataHelpers\DataHelpersConfig;
DataHelpersConfig::set('cache.max_entries', 1000);
DataHelpersConfig::set('cache.default_ttl', 3600);

Caching improves performance for repeated operations.

You can use environment variables to configure Data Helpers:

DATA_HELPERS_PERFORMANCE_MODE=true
DATA_HELPERS_CACHE_ENABLED=true