--config) is critical. Less relevant for web-based Laravel applications unless extending Artisan.symfony/console and symfony/dependency-injection, adding ~10MB and potential complexity. Justify only if leveraging Symfony’s advanced CLI features (e.g., argument parsing, help commands).ParameterBag and set-based resolution differ from Laravel’s config() system. Merging resolved configs into Laravel’s array structure risks precedence conflicts (e.g., CLI args vs. .env variables)..env > config/ > CLI args, while Symfony’s ParameterBag prioritizes CLI/config files. Requires custom logic to align.ParameterBag integration. Need a wrapper to convert resolved configs into Laravel’s format.bootstrap/app.php, not a Kernel. Resolver must be injected early (e.g., in a ServiceProvider or Console command).Input with Symfony’s ArgvInput for CLI flag parsing.env() and Symfony’s config resolution (e.g., duplicate keys).ParameterBag vs. Laravel’s recursive merge) could lead to unexpected behavior.ParameterBag) may introduce overhead for CLI tools. Benchmark critical paths.config() + Dotenv may suffice. Symfony’s features (e.g., argument parsing) justify the dependency..env vs. config files (e.g., CLI overrides all, or .env takes priority).config/app.php or cached configs?null values, duplicate keys, and empty configs.Config component, or build a minimal Laravel-specific resolver?php artisan my:tool --config=custom.php).symfony/console (for ArgvInput), symfony/dependency-injection (for ParameterBag).symfony/flex (for autoloader), symfony/yaml (if supporting YAML configs).Phase 1: Proof of Concept
php artisan make:command TestConfigResolver
use Symplify\SetConfigResolver\SetAwareConfigResolver;
use Symfony\Component\Console\Input\ArgvInput;
protected function handle()
{
$resolver = new SetAwareConfigResolver(new MySetProvider());
$config = $resolver->resolveFromInputWithFallback(new ArgvInput(), ['config/test.php']);
$this->info('Resolved config:', print_r($config, true));
}
Phase 2: Adapter Layer
ServiceProvider to:
ParameterBag to Laravel’s config array..env).// app/Providers/ConfigResolverServiceProvider.php
public function register()
{
$this->app->singleton('config.resolver', function () {
return new LaravelConfigAdapter(
new SetAwareConfigResolver(new MySetProvider())
);
});
}
LaravelConfigAdapter to merge configs into Laravel’s system:
class LaravelConfigAdapter
{
public function __construct(private SetAwareConfigResolver $resolver) {}
public function resolve(array $fallbackConfigs): array
{
$symfonyConfig = $this->resolver->resolveFromInputWithFallback(
new ArgvInput(),
$fallbackConfigs
);
return $this->convertToLaravelConfig($symfonyConfig);
}
private function convertToLaravelConfig(array $symfonyConfig): array
{
// Custom logic to handle precedence and format
return array_merge(
config()->all(),
$symfonyConfig
);
}
}
Phase 3: Artisan Integration
resolve() method or create a ConfigAwareCommand trait:
// app/Traits/ConfigAwareCommand.php
trait ConfigAwareCommand
{
protected function resolveConfig(array $fallbackConfigs = []): void
{
$config = app('config.resolver')->resolve($fallbackConfigs);
config($config);
}
}
class MyCommand extends Command
{
use ConfigAwareCommand;
protected function handle()
{
$this->resolveConfig(['config/mytool.php']);
// Use config() as usual
}
}
symfony/yaml + spatie/array-to-object)..env integration. Merge manually or use a wrapper like vlucas/phpdotenv.Input system. Override Laravel’s Input facade if needed.php artisan my:tool).ConfigAwareCommand trait.config() loading with the resolver (high risk; test thoroughly).^5.4).symfony/console vulnerabilities).null values).config:cache) may not reflect resolver changes. Clear cache on config updates.ExceptionHandler for consistency..env).How can I help you explore Laravel packages today?