mradcliffe / laravel-settings-injector
Laravel Settings Injector
Installs: 18
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 1
pkg:composer/mradcliffe/laravel-settings-injector
Requires (Dev)
- laravel/framework: ~5.3
- phpspec/prophecy: ~1.6
- phpunit/phpunit: ~4.8
This package is auto-updated.
Last update: 2025-10-21 09:46:22 UTC
README
laravel-settings-injector provides a bootstrapper replacement for the default LoadConfiguration bootstrapper from Laravel.
This allows you to create a directory to manage settings from outside of the application directory with symlinks so that various environment-specific variables can be managed at a systems-level for production and other internal enviroments.
This is probably not useful for many installations of Laravel, however due to recommendations of not using dotenv files for production environment variables this is necessary to obfuscate production variables from the application repository. The advantage is that the variables are scoped to LoadConfiguration instead of using global environment variables.
Installation
composer require mradcliffe/laravel-settings-injector
Configuration
- Modify
app/Http/Kernel.php. - Replace
\Illuminate\Foundation\Bootstrap\LoadConfigurationwith\Radcliffe\LaravelSettingsInjector\Bootstrap\LoadConfigurationeither by modifying an existing::$bootstrappersprotected variable or doing so within the::bootstrappers()method of that class. - Modify
app/Console/Kernel.phpand add\Illuminate\Foundation\Console\Kernel::$bootstrappersprotected variables to there, and do the same replacement as in #2 above.
Usage
See tests directory for some example fixtures.
- Create a
settingsdirectory in app root. - Provision files outside of the webroot, but required somehow by
settings/settings.php. See image below. - Use those variables as normal in
config/*.phpto configure your application.- Note that any defines or requires could potentially happen more than once due to the way that Laravel works. Specifically
artisan config:cachewill load configuration after configuration has already been loaded so any use ofdefineorrequirewithinsettings/settings.phpor any file it requires needs to take that into consideratino.
- Note that any defines or requires could potentially happen more than once due to the way that Laravel works. Specifically
