2
votes

The Zend Website suggests that I can map an entire string with url delimiters in it ("/") to one url param in the zend router: Zend Framework 2 - Router

So I created this route:

'myRoute' => array (
        'type' => 'segment',
        'options' => array (
                'route' => '/someAction/:params{-}',
                'defaults' => array (
                        'controller' => 'Application\Controller\myController',
                        'action' => 'someAction'
                )
        ),
        'may_terminate' => true,
),

Since this is a child route of /myController, I can now call: http://myHost/myController/someAction/someParam1(someValue)/bookingCode(X79P00A3CB0002:000000010000000D000C80F601D))

This results in one route parameter called "params" which I can then analyze and explode myself.

This works for the URL specified above, but not for this URL: http://myHost/myController/someAction/someParam1(someValue)/bookingCode(aclGWciSaclGWciSaclGWciSmZmSaclsz1tF9KtSudlGWciSacl1eJlYeJl3edlWWYquHelC_IueXciSyJnSudl1eJlYeJlYedlw9KuYWsq4Kto0ielyrevSaclWWcmSadlYWYtiLevSmuroXYmSeKq-2-)

Currently I am thinking that I am either limited by an URL segment length restriction, but I don't get any error like that. Zend just answers "Requested page is not resolvable".

Or I am not understanding the "/:params{-}" part of my route.

Can someone explain or provide a solution?

*edit 1: So I found that the "-" characters in the second URL are the problem, though I do not understand why. If I remove them from the URL, routing works fine.

1

1 Answers

0
votes

The major issue seemed to be the hyphen in the url. I changed my route from a segment type to solve this problem. The new route looks like this:

'myRoute' => array (
    'type' => 'Zend\Mvc\Router\Http\Regex',
    'options' => array(
        'regex' => '/someAction/(?<params>[a-zA-Z0-9():/_-]*)',
        'defaults' => array(
            'controller' => 'Application\Controller\myController',
            'action' => 'someAction',
        ),
        'spec' => '/myController/%params%',
    ),
        'may_terminate' => true,
),

I don't know why the hyphen is a problem though. So if someone could elaborate, I will gladly mark as answer!