Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I guess typing all this out jogged something in my memory as I remembered something odd about the routing config from the tutorial when I went through it several days ago.</p> <p>Sure enough, in <a href="http://framework.zend.com/manual/2.1/en/user-guide/routing-and-controllers.html" rel="nofollow">Routing and controllers</a>, the example displayed currently shows:</p> <pre><code>'router' =&gt; array( 'routes' =&gt; array( 'album' =&gt; array( 'type' =&gt; 'segment', 'options' =&gt; array( 'route' =&gt; '/album[/][:action][/:id]', 'constraints' =&gt; array( 'action' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*', 'id' =&gt; '[0-9]+', ), 'defaults' =&gt; array( 'controller' =&gt; 'Album\Controller\Album', 'action' =&gt; 'index', ), ), ), ), ), </code></pre> <p>Here, the route shows the trailing slash after <em>album</em> encapsulated on it's own, which allows for <em>optional</em> matching. However, the paragraph immediately following the example, plus several comments, make reference to the route previously being <code>/album[/:action][/:id]</code>. The current implementation has the effect of redirecting to the route with a trailing slash. Despite being optional, the controller puts it there so it fails the phpunit test (which judging by the tutorial section's comments, used to be in this portion of the tutorial but now has it's own separate section).</p> <p>I've verified that changing the route to the older example does indeed redirect without a trailing slash and therefore the phpunit test passes but I then lose my ability to optionally route to this section with a trailing slash. I would prefer to be able to optionally match on this.</p> <p>So, the "How is this happening?" question has been resolved but I would really like to know how to test for an optional match or if I should just revise the assertion test to check for a trailing slash here. Also, why does Zend\Mvc (or whichever relevant part of the framework, if otherwise) tack on the trailing slash if it's optional?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload