Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Config Bundle Laravel Package

aaronadal/config-bundle

Symfony bundle that loads configuration from multiple YAML files automatically. Define default and environment-specific glob paths; files in the current environment override defaults. Uses Symfony cache for fast startup and cleaner parameter/service management.

View on GitHub
Deep Wiki
Context7

Config bundle

This bundle offers some improvements in the configuration management of your Symfony application.

It allows you to write your application configuration to multiple environment-dependant files that will be loaded automatically when the application starts.

What benefits does this bundle offer?

  • It offers an important DX: you can organize your configuration into several files without having to include them manually in your main config file.

  • It allows you to benefit from Symfony environments in a powerful way, and write different configurations for each of them easily.

  • It also provides a way to first determine a default set of services and parameters and then override them depending on the environment.

  • It takes advantage of the Symfony cache system, so it does not affect the loading time of your application.

Getting started

Install

You can use Composer to install this bundle:

composer require aaronadal/config-bundle

After this, you need to register the bundle in your application kernel:

// app/AppKernel.php

public function registerBundles()
{
    return [
        // ...
        new Aaronadal\ConfigBundle\AaronadalConfigBundle(),
        // ...
    ];
}

NOTE: Do not forget to place it above the bundles that depend on the dynamically loaded parameters.

Configure

You can configure two locations (through glob patterns) in which the bundle will look for the configuration files:

  • Defaults: determines the path where default configuration files reside.
  • Environment: determines the path where environment-dependant configuration files reside. As you can see in the following example, there is an :env placeholder that references the environment at runtime (default: dev or prod).

Let's configure it in the config.yml:

aaronadal_config:
    location:
        defaults:    config/parameters/defaults/*.yml
        environment: config/parameters/:env/*.yml

That's all! Quite simple. Now, all yml files inside the config/parameters/defaults/ folder will always be loaded and if the environment is, for example, dev, all the yml files inside the config/parameters/dev/ folder will override the default values (or will define new ones if not defined).

NOTE 1: Due to the way in which parameters are resolved by Symfony, parameters cannot be used in the definition of the locations. Only the :env placeholder is valid.

NOTE 2: The locations may be absolute or relative paths. If they are relative paths, the kernel.root_dir is taken as the reference path.

Creating your own environments

Don't you know how to create new environments in Symfony?

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views