Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
Configuration in Slim Framework
Mar 16, 2016 @ 12:30:10

If you're a Slim framework user you should check out the latest post on Rob Allen's site covering all things configuration in using the framework and it's simple configuration handling.

Configuration in Slim Framework is nice and simple: the App's constructor takes a configuration array for the DI container.

He shows how to pass in the configuration as a optional constructor parameter on the main application, including a settings value containing some of the common options. These include the displayErrorDetails flag to show/hide detailed error messages and a logger setup (in his example Monolog). He also shows how to:

  • get settings from the configuration
  • use a separate file for the configuration
  • using a .env configuration file
  • combining multiple configuration files

He includes code examples for each of these cases as well as a method for using a non-array structure (like YAML or XML) via the ZendConfig component.

tagged: slim slim3 slimframework configuration option tutorial settings

Link: https://akrabat.com/configuration-in-slim-framework/