use Illuminate\Support\Facades\Config; // Retrieve a setting by its key $setting = Config::get('app.timezone'); // Retrieve a setting by searching against a parameter $setting = Config::get('database.connections.mysql.host', 'localhost');
use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; class MyBundleConfiguration implements ConfigurationInterface { public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('my_bundle'); $treeBuilder->getRootNode() ->children() ->scalarNode('api_key') ->defaultValue('') ->end() ->booleanNode('debug') ->defaultFalse() ->end() ->end(); return $treeBuilder; } } $config = new MyBundleConfiguration(); $settings = $config->getConfigTreeBuilder()->buildTree()->toArray(); $apiKey = $settings['my_bundle']['api_key']; $debug = $settings['my_bundle']['debug'];In this example, the `getConfigTreeBuilder` method is used to define a configuration tree with a scalar (api_key) and boolean (debug) node. The `buildTree` method is then called to create the actual configuration object, which can be used to retrieve settings through an array. The package library in use is Symfony's `symfony/config` package.