What is the difference between 'url' and 'path' in symfony2.3

Viewed 34124

The document said

{# src/Acme/ArticleBundle/Resources/views/Article/recentList.html.twig #}
{% for article in articles %}
    <a href="{{ path('article_show', {'slug': article.slug}) }}">
        {{ article.title }}
    </a>
{% endfor %}

also, can use 'url' like this:

<a href="{{ url('_welcome') }}">Home</a>

it confused me what is the difference between using 'url' and 'path'?

2 Answers

url Twig function generates absolute path path Twig function generates / related url

Example we have http://sf2sandbox.local with AcmeDemoBundle

{{ path('_welcome') }} produce /
{{ url('_welcome') }} produce http://sf2sandbox.local/
Related