• 11

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Where do I store general config parameters in Silex?

I have some general parameters I would like to share all along my application like path information ("baseurl"). Where would you ideally store this information in Silex?

After writing this question I came across the ConfigServiceProvider:

You can store your config data in json or yml files and access them through $app["name.of.config.var"].

Replacements to add values dynamically to the config files on setup are also supported. The only thing I did not manage so far is to inject the baseurl via the $app["request"] api into the config files.

  • 12
Reply Report

I would store it in Silex\Application. It's a DI-container based on Pimple, so you can just do:

$app['baseUrl'] = '/';

Since $app pretty much gets passed around everywhere, you will also have access to this everywhere.

  • 4
Reply Report
      • 1
    • I have a config.php file which I include after the Application instance has been bootstrapped, it just sets config values on $app. This is the best solution.

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions