Ask your Symfony questions! Pay money and get answers fast! (more info)

Why does url_for() mangle URLs when used in a yaml file? Symfony


This is a follow-up to the question I just asked. It was suggested that I can use url_for() in yaml files if I load the helper. So I did. But now url_for() is giving me mangled urls.

I'm doing this in app.yml:

janrain_rpx_login_processing: '<?php echo url_for('user/rpxLogin', true) ?>'

and in the template I call it like this:

<?php echo sfConfig::get('app_urls_janrain_rpx_login_processing') ?>

and I'm getting this:

Any thought why it would mash the URL like that?

And this:


janrain_rpx_login_processing: '<?php echo url_for('user/rpxLogin') ?>'

gives me this:


Why? Is there a better function to use than url_for()?

Answers (2)


Pierre Minnieur answers:

Just store the name of the route in your YAML file. You can then use url_for(sfConfig::get('app_urls_janrain_rpx_login_processing')) to render the link in your templates. That's a common approach and is widely used (e.g. sf*GuardPlugin).

Lawrence Krubner comments:

So I can not use URL methods in the yaml file? You are suggesting that this is impossible?


Kiril Angov answers:

Pierre is right, why would you store the result of url_for, when you can just store the route name and generate the URL in the template PHP files.