如何从symfony2中的yml文件中获取数据[关闭]

I want to create the file called setting.yml and it will have data like

Route1: users
Route2 : profile

So that in my controller i can get the route1 from that Yml file

File is in /app/config/settings.yml and not included in config.yml

You can do two things:

If your configuration is simple, add the values you need under a "parameters" entry, either in your main config.yml file or in a file which you import from your main config.file. For example:

parameters:
    Route1: users
    Route2 : profile

Then in your controller, use this code to get one of the parameters:

$route = $this->container->getParameter('Route1');

Or, if you want a really flexible configuration, you can implement a semantic configuration for your bundle. See this link for all the information you will need:

http://symfony.com/doc/master/cookbook/bundles/extension.html

You will need to import it in your config file for it to work

config.yml

imports:
    - { resource: settings.yml }

But I am not sure you are using routing correctly

See the documentation for how to use Routing properly