It does make sense. I'm getting the segments now; they will come in handy.
Thanks.

Now this brings up another question: is there a way to move "parent" into
application.config.php? I'm not finding any way to add routes (that work)
into application.config.php. /a/:version/rest (version is important, good
catch) will be an invalid route but common across all modules.

.../:controller then maps to a controller within a specific module defined
by routes within module.config.php.

Our Modules are packaged pieces (we have about 16). Right now we're using a
custom routing solution; I'm currently in the process of investigating a
way to migrate our routing into a ZF2 understandable REST MVC structure.

Thanks, Mat

Philip


---
Philip
[email protected]
http://www.gpcentre.net/


On Mon, Aug 5, 2013 at 2:17 PM, Matthew Weier O'Phinney <[email protected]>wrote:

> On Fri, Aug 2, 2013 at 6:09 PM, Philip G <[email protected]> wrote:
> > How do I work on configuring ZF2 route to work with file path as a
> > parameter:
> > /a/2.1/route/component/optional/resource/id.jpg
> >
> > /a/2.1/route - is static. It's always there in the URL for every module
> > ever called.
> >
> > /component/ - is required. It is our component for REST calls. The
> > component is to map directly to a controller.
> >
> > /optional/resource/id.jpg - is an optional file path, that may or may not
> > be there.
>
> I'd do this as a set of nested routes:
>
>     'parent' => array(
>         'type' => 'segment',
>         'options' => array(
>             'route' => '/a/:version/route',
>             'criteria' => array(
>                 'version' => '\d+\.\d+',
>             ),
>         ),
>         'may_terminate' => false,
>         'child_routes' = array(
>             'component' => array(
>                 'type' => 'segment',
>                 'options' => array(
>                     'route' => '/:controller',
>                     'defaults' => array(
>                          'action' => 'index',
>                     ),
>                 ),
>                 'may_terminate' => true,
>                 'child_routes' = array(
>                     'path' => array(
>                         'type' => 'segment',
>                         'options' => array(
>                             'route' => '/:fullpath',
>                         ),
>                     ),
>                 ),
>             ),
>         ),
>     ),
>
> Some notes:
>
> - Since the version is clearly necessary, I've made it a required
> argument, with criteria.
> - The parent route may not terminate; it requires a controller. Which
> is the first child in the route.
> - The "component" route defines the "controller" as a required
> argument. That route is marked as able to terminate, and defines a
> default for the action.
> - A final child route, "path" has a non-optional "fullpath" argument.
> However, since its direct parent can terminate, it is in effect
> optional for the purposes of matching.
>
> Hope that makes sense!
>
> >
> > my attempts aren't working:
> > I've created a route segment, using the AlbumRest examples. route =>
> > '/a[/:version]/route/album-rest[/:fullpath]'
> >
> > However, it only works with one trailing path after "album-rest." As soon
> > as I use "/option/resource" it fails.
> >
> > ---
> > Philip
> > [email protected]
> > http://www.gpcentre.net/
>
>
>
> --
> Matthew Weier O'Phinney
> Project Lead            | [email protected]
> Zend Framework          | http://framework.zend.com/
> PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
>

Reply via email to