use Silex\Application; use Silex\Provider\ConfigServiceProvider; $app = new Application(); $app->register(new ConfigServiceProvider(), array( 'config.path' => '/path/to/config/files' )); // Access a configuration setting $dsn = $app['config']['database']['dsn'];
use Silex\Application; use Symfony\Component\Yaml\Yaml; use Silex\Provider\ConfigServiceProvider; $app = new Application(); $app->register(new ConfigServiceProvider(), array( 'config.options' => Yaml::parse(file_get_contents(__DIR__.'/config.yml')), )); // Access a configuration setting $dsn = $app['config']['database']['dsn'];In this example, we're using the Yaml encorder to parse a YAML configuration file and loading the options into the ConfigServiceProvider. We can then access specific settings using the $app['config'] array syntax. Overall, the Silex Application Config is a lightweight and flexible library that makes it easy to manage application settings. It's part of the Silex micro-framework and can be installed via Composer.