Installation
composer require avexsoft/donkey
Register the service provider in config/app.php under providers:
Avexsoft\Donkey\DonkeyServiceProvider::class,
First Use Case
Define a config override in config/donkey.php:
return [
'app.debug' => env('APP_DEBUG', false),
'mail.driver' => env('MAIL_DRIVER', 'smtp'),
];
Overrides will now take precedence in production without modifying .env.
config/donkey.php – Centralized override definitions.DonkeyServiceProvider – Boot logic for merging configs.Donkey::override() – Programmatic overrides (if needed).Environment-Specific Overrides
Use donkey.php to define production defaults:
return [
'services.loggly.key' => env('LOGGLY_KEY', null),
'queue.connections.redis.database' => env('REDIS_QUEUE_DB', 1),
];
.env if keys are missing.Dynamic Overrides via Facade Override configs programmatically (e.g., in a service provider):
Donkey::override('app.locale', 'en_US');
Integration with Laravel Config Access overrides like any other config:
$locale = config('app.locale'); // Respects Donkey overrides
env() fallbacks in donkey.php to keep .env as the source of truth.mail, queue, services).Donkey overrides in tests:
Donkey::shouldReceive('override')->andReturnUsing(fn($key, $value) => config([$key => $value]));
Priority Conflicts
APP_ENV). Test locally with:
php artisan config:clear && php artisan config:cache
array_merge manually if needed).Caching Issues
php artisan config:clear
php artisan config:cache
Facade vs. Config File
donkey.php for static overrides; use Donkey::override() sparingly (e.g., for runtime changes).dd(config('donkey')); // Check if your overrides are registered
if (app()->environment('production')) {
// Donkey overrides apply here
}
Custom Override Logic
Extend the service provider’s boot() method to add dynamic logic:
public function boot()
{
if (someCondition()) {
Donkey::override('custom.key', 'dynamic_value');
}
}
Environment-Specific Files
Use donkey.php in config/ and override it in config/production/donkey.php for environment-specific tweaks.
Validation
Validate overrides in donkey.php:
return [
'app.timezone' => env('APP_TIMEZONE', 'UTC'),
'cache.default' => env('CACHE_DRIVER', 'file'), // Default to 'file' if unset
];
How can I help you explore Laravel packages today?