Dotenv or ParameterBag in hybrid stacks). For pure Laravel, this is indirectly relevant—Laravel’s .env handling is already robust, but this bundle could complement custom Symfony-integrated services (e.g., API platforms, legacy Symfony microservices)..env variables into structured formats (e.g., arrays, booleans, nested objects)—aligns with Laravel’s need for flexible environment variable handling (e.g., config('services.array_keys')). However, Laravel’s native env() helper and config() caching already handle basic cases.parameters.yml flexibility) suggests it targets Symfony’s rigid dotenv parsing. Laravel’s env() is more permissive, reducing the perceived "pain" this bundle addresses.Dotenv component (not natively in Laravel). For Laravel, integration would need:
symfony/dotenv as a Composer dependency).Dotenv loader or extend it via service providers.// app/Providers/AppServiceProvider.php
use Symfony\Component\Dotenv\Dotenv;
use C0ntax\EnvProvidersBundle\Loader\EnvProviderLoader;
public function boot(): void {
$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/../.env');
$dotenv->addProviderLoader(new EnvProviderLoader());
}
ENV_VAR= → [] vs. null)..env).
This bundle could fill those gaps if adapted to Laravel’s service container.Dotenv for one bundle may introduce unnecessary complexity.Dotenv loader might override or conflict with the bundle’s providers.Dotenv evolves..env values, nested arrays)..env into complex config structures) not covered by native tools?env() + custom parsing logic (e.g., explode(',', env('ENV_VAR'))).vlucas/phpdotenv (more maintained, Laravel-friendly).Dotenv directly?.env parsing?Dotenv providers.Dotenv as a complementary loader alongside Laravel’s.// config/app.php
'providers' => [
// ...
Symfony\Component\Dotenv\Dotenv::class,
C0ntax\EnvProvidersBundle\C0ntaxEnvProvidersBundle::class,
],
config() system.// app/Providers/EnvProvidersServiceProvider.php
use C0ntax\EnvProvidersBundle\Loader\EnvProviderLoader;
public function register(): void {
$loader = new EnvProviderLoader();
$this->app->extend('config', function ($config) use ($loader) {
$config->set('env_providers', $loader->load(__DIR__.'/../.env'));
return $config;
});
}
app/Helpers/env.php):
function envArray(string $key, bool $returnNullIfEmpty = false): ?array {
$value = env($key);
return $returnNullIfEmpty && empty($value) ? null : explode(',', $value);
}
.env variables to test parsing behavior..env providers.try {
$arrayConfig = config('env_providers.array_thing');
} catch (\Exception $e) {
$arrayConfig = ['default', 'values'];
Log::warning("Env provider failed: {$e->getMessage()}");
}
Dotenv).Dotenv if not isolated.ENV_VAR=).ENV_VAR=bad,"data").composer require symfony/dotenv c0ntax/env-providers-bundle
config/bundles.php (Symfony) or AppServiceProvider (Laravel).return_null_if_empty in config/packages/c0ntax_env_providers.yaml (Symfony) or config/services.php (Laravel)..env providers:
# config/services.yaml (Symfony)
parameters:
array_config: '%env(array:APP_ARRAY_VAR)%'
$config = envArray('APP_ARRAY_VAR');
.env files).Dotenv updates.vlucas/phpdotenv + custom parsing).Dotenv debugging tools.Dotenv (could change in future versions).Dotenv)..env Files: Test with 1000+ variables to check memory/CPU usage.How can I help you explore Laravel packages today?