<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>no</td>
</tr>
<tr>
<td>Feature request?</td>
<td>yes</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>yes/no/dunno</td>
</tr>
<tr>
<td>Symfony version</td>
<td>3.2</td>
</tr>
</tbody>
</table>
<p dir="auto">Routing works like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="wallet_read:
  path: /wallet/{id}.{_format}"><pre class="notranslate"><code class="notranslate">wallet_read:
  path: /wallet/{id}.{_format}
</code></pre></div>
<p dir="auto">Would be nice to have that a bit more intelligent like</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="wallet_read:
  path: /wallet/{wallet.id}/{wallet.title}.{_format}"><pre class="notranslate"><code class="notranslate">wallet_read:
  path: /wallet/{wallet.id}/{wallet.title}.{_format}
</code></pre></div>
<p dir="auto">So that URL generator like in Twig receive the entity and does the rest of the magic:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="path('wallet_show', {wallet: wallet})"><pre class="notranslate"><code class="notranslate">path('wallet_show', {wallet: wallet})
</code></pre></div>
<p dir="auto">How about that?</p>
<p dir="auto">There is currently a known limitation when using route imports that makes it impossible to to have a root route <code class="notranslate">/</code> be imported under a prefix without a trailing slash. See <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="4639548" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/4322" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/4322/hovercard" href="https://github.com/symfony/symfony/issues/4322">#4322</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1409350" data-permission-text="Title is private" data-url="https://github.com/silexphp/Silex/issues/149" data-hovercard-type="issue" data-hovercard-url="/silexphp/Silex/issues/149/hovercard" href="https://github.com/silexphp/Silex/issues/149">silexphp/Silex#149</a></p>
<p dir="auto">I propose to solve this problem in a generic way by offering an option when importing routes to remove or add trailing slashes (which defaults to null, meaning not modifying anything):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="AcmeBusinessBundle_client:
    resource: &quot;@AcmeBusinessBundle/Resources/config/routing/client.yml&quot;
    prefix:   /clients
    trailing_slashes: true|false|null"><pre class="notranslate"><code class="notranslate">AcmeBusinessBundle_client:
    resource: "@AcmeBusinessBundle/Resources/config/routing/client.yml"
    prefix:   /clients
    trailing_slashes: true|false|null
</code></pre></div>
<p dir="auto">This way, the users can unify the path on import the way they want.</p>
<p dir="auto">So for example</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="acme_business_client_list:
    path:  /
    defaults: { _controller: AcmeBusinessBundle:Client:list }"><pre class="notranslate"><code class="notranslate">acme_business_client_list:
    path:  /
    defaults: { _controller: AcmeBusinessBundle:Client:list }
</code></pre></div>
<p dir="auto">imported with <code class="notranslate">trailing_slashes: false</code> under <code class="notranslate">prefix: /clients</code> will result in path <code class="notranslate">/clients</code> instead of <code class="notranslate">/clients/</code>.</p>
<p dir="auto">The other case with <code class="notranslate">trailing_slashes: true</code> is helpful when you import third party routes without trailing slash but you decided that you app should use training slashes everywhere consistently.</p>