<p>I always tend to forget these built-in <strong>Symfony</strong> functions for making links.</p>

[{'answer_id': 34426, 'author': 'andyuk', 'author_id': 2108, 'author_profile': 'https://Stackoverflow.com/users/2108', 'pm_score': 1, 'selected': False, 'text': "<p>This advice is for symfony 1.0. It probably will work for later versions.</p>\n\n<p><strong>Within your sfAction class</strong>:</p>\n\n<p>string  genUrl($parameters = array(), $absolute = false)</p>\n\n<p>eg. \n$this->getController()->genUrl('yourmodule/youraction?key=value&amp;key2=value', true);</p>\n\n<p><strong>In a template</strong>:</p>\n\n<p>This will generate a normal link.</p>\n\n<p>string link_to($name, $internal_uri, $options = array());</p>\n\n<p>eg. \nlink_to('My link name', 'yourmodule/youraction?key=value&amp;key2=value');</p>\n"}, {'answer_id': 36026, 'author': 'jamz', 'author_id': 3734, 'author_profile': 'https://Stackoverflow.com/users/3734', 'pm_score': 4, 'selected': True, 'text': '<p>If your goal is to have user-friendly URLs throughout your application, use the following approach:</p>\n\n<p>1) Create a routing rule for your module/action in the application\'s routing.yml file.  The following example is a routing rule for an action that shows the most recent questions in an application, defaulting to page 1 (using a pager):</p>\n\n<pre><code>recent_questions:\n   url:    questions/recent/:page\n   param:  { module: questions, action: recent, page: 1 }\n</code></pre>\n\n<p>2) Once the routing rule is set, use the <code>url_for()</code> helper in your template to format outgoing URLs.</p>\n\n<pre><code>&lt;a href="&lt;?php echo url_for(\'questions/recent?page=1\') ?&gt;"&gt;Recent Questions&lt;/a&gt;\n</code></pre>\n\n<p>In this example, the following URL will be constructed: <code>http://myapp/questions/recent/1.html</code>.</p>\n\n<p>3) Incoming URLs (requests) will be analyzed by the routing system, and if a pattern match is found in the routing rule configuration, the named wildcards (ie. the <code>:/page</code> portion of the URL) will become request parameters.</p>\n\n<p>You can also use the <code>link_to()</code> helper to output a URL without using the HTML <code>&lt;a&gt;</code> tag.</p>\n'}, {'answer_id': 372205, 'author': 'thrashr888', 'author_id': 46443, 'author_profile': 'https://Stackoverflow.com/users/46443', 'pm_score': 0, 'selected': False, 'text': "<p>In addition, if you actually want a query string with that url, you use this:  </p>\n\n<pre><code>link_to('My link name', 'yourmodule/youraction?key=value&amp;key2=value',array('query_string'=&gt;'page=2'));\n</code></pre>\n\n<p>Otherwise, it's going to try to route it as part of the url and likely break your action.</p>\n"}, {'answer_id': 8052024, 'author': 'priyabagus', 'author_id': 1035374, 'author_profile': 'https://Stackoverflow.com/users/1035374', 'pm_score': 0, 'selected': False, 'text': '<p>You can generate URL directly without define the rule first.</p>\n\n<p>If you want to generate URL in the actions, you can use <strong>generateUrl()</strong> helper:</p>\n\n<pre><code>$this-&gt;generateUrl(\'default\', array(\'module\'=&gt;\'[ModuleName]\',\'action\'=&gt;\'[ActionName]\'))\n</code></pre>\n\n<p>If you want to generate URL in the templates, you can use <strong>url_for()</strong> helper:</p>\n\n<pre><code>url_for(\'[ModuleName]/[ActionName]\', $absolute)\n</code></pre>\n\n<p>set $absolute as true/false, dont forget to use echo if you want to display it.</p>\n\n<p>But if you want to make a <strong>link</strong> (something like <code>&lt;a href=""&gt;&lt;/a&gt;</code>), <strong>link_to()</strong> helper will do.</p>\n'}]
['https://Stackoverflow.com/questions/34411', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2108/']