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

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$5
How can I generate URLs inside a YAML file? Like url_for()?

Symfony allows me to use PHP to set a value in yaml files. I am curious, is there a way to set a URL? Is there any function like url_for() or gen_url() that would work in app.yml? Failing that, what is the best way for me to get the domain and sub-domain in app.yml?

This question has been answered.

Lawrence Krubner | 07/27/10 at 12:17pm Edit


(6) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    07/27/10
    1:32pm
    Arturo Linares says:

    First load the helper and then call the function:


    <?php
    sfLoader::loadHelpers('Url');
    ?>

    all:
    test:
    url: <?php echo url_for('@homepage') ?>



    You can always call the $_SERVER['SERVER_NAME'] to get the information you need for the domain/subdomains.

    Previous versions of this answer: 07/27/10 at 12:25pm | 07/27/10 at 12:27pm

  • avatar
    Last edited:
    07/27/10
    12:29pm
    Yura Rodchyn says:

    Arturo Linares is write.
    damn he was quick :)

  • avatar
    Last edited:
    07/27/10
    1:23pm
    GlobalOrangeLab says:

    Just load the Url helper in .yml file and you can use 'url_for' anywhere in that .yml file.


    <?php sfLoader::loadHelpers('Url'); ?>

    all:
    test:
    url: <?php echo url_for('@homepage') ?>

  • avatar
    Last edited:
    07/27/10
    1:22pm
    Lawrence Krubner says:

    Oddly enough, I'm doing this:

      urls:
    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:

    http://dev.dev.com/dev.phpmodule=user/action=rpxLogin


    Any thought why it would mash the URL like that?

  • avatar
    Last edited:
    07/27/10
    1:26pm
    Lawrence Krubner says:

    And this:

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


    gives me this:


    /cao_dev.phpmodule=user/action=rpxLogin


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

  • avatar
    Last edited:
    07/27/10
    1:31pm
    Lawrence Krubner says:

    Actually, I will post all this as a separate question.

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.