How to define parameters in a PHP config file in Symfony?

243
March 17, 2018, at 7:33 PM

I am using Symfony 4.0 and trying to use a PHP configuration file instead of a YAML file. So I went into the services.yml and imported the PHP file like so:

imports:
    - { resource: 'foobar.php' }

However I can not find any information online on how the parameters should be defined inside the PHP file. How can I define parameters in the foobar.php in order to be able to access them using $container->getParameter()? Do I need to set them using $container->setParameter() inside the imported PHP file?

Answer 1

It's like in docs examples (https://symfony.com/doc/current/service_container/parameters.html) :

<?php
// adds a new parameter
$container->setParameter('ahs_test', 'testvalue');

Variable $container will be available in script.

Rent Charter Buses Company
READ ALSO
Update Or Add Data in Multidimensional Array

Update Or Add Data in Multidimensional Array

Hello i am creating a best recently product view based on php cookiesfirst of all whenever user view some data so i store cookie as follow

152
Google vision API changes app pictures with its own pictures

Google vision API changes app pictures with its own pictures

I am making an app using Google Vision API for face detectionAs the pictures show, my app displays two images normally without Google Vision, but with it Google Vision automatically changes the two images with its own

157
Android webview permissions

Android webview permissions

I have to write an android app that wraps an existing website using the WebView componentInside this website, users can do some video calls, after according access to the navigator using (Navigator permissions)

181