magic router

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

magic router

Simon Walter
Hi all,

I read over some of the IRC meeting log. I wanted to comment about the magic
router idea. I don't know of anyone else who "stumbled" with this. I think I
was the only one. So I feel I need to comment about this lest a bunch of work
goes into making this magic router. Maybe it is needed. Though I think it's
really down to the documentation and examples.

That is where I was thrown off. After hearing the explanations and doing more
reading, I'm able to get the routing structure I prefer:
/module/controller/action

It's not anything "magic", it just how the module config is defined among a
few other things.

Another thing I'd like to mention about the examples is that the "Application"
module that comes with the ZendSkeletonApplication, IMHO, is much better
suited to a module example over the ZendSkeletonModule. After having read
through the "Application" module code, everything was much clearer. The
ZendSkeletonModule relies too much on ZendSkeletonApplication's "Application"
module so that one cannot see what is really going on. The documentation
should really explain everything unless there is a "standard" module skeleton
that perhaps Zend_Tool (Zend\Tool?) will output. The Quick Start is much too
sparse and the resulting code did not work - it doesn't match what's in the
repos and the ZF library included in ZendSkeletonApplication was not the same
build (version) as HEAD. I worked through the errors and changed a lot of the
example to get it to work as it said it should. Then was dis-satisfied with
the routing.

In order to save others the same issues, I suggest effort be put into the docs
rather than a magic router, because, after all, the exact same result can be
achieved with the performance improvements.

Cheers,

Simon

Here is what my module.config.php looked after I got it set up how I liked it:

<?php
return array(
    'bootstrap_class' => 'Test\Bootstrap',
    'layout'          => 'layouts/layout.phtml',
    'routes' => array(
        'helloworld' => array(
            'type'    => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route' => '/helloworld',
                'defaults' => array(
                    'controller' => 'hello',
                    'action'     => 'world',
                ),
            ),
        ),
        'default' => array(
            'type'    => 'Zend\Mvc\Router\Http\Segment',
            'options' => array(
                'route'    => '/test[/:controller[/:action]]',
                'constraints' => array(
                    'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                ),
                'defaults' => array(
                    'controller' => 'index',
                    'action'     => 'index',
                ),
            ),
        ),
    ),
    'di' => array(
        'instance' => array(
            'alias' => array(
                'hello' => 'Test\Controller\HelloController',
                'view'  => 'Zend\View\PhpRenderer',
            ),
            'Zend\View\PhpRenderer' => array(
                'parameters' => array(
                    'resolver' => 'Zend\View\TemplatePathStack',
                    'options'  => array(
                        'script_paths' => array(
                            'test' => __DIR__ . '/../views',
                        ),
                    ),
                ),
            ),
        ),
    ),
);



--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: magic router

Tomáš Fejfar
I guess it really goes down to the docs. The docs should present "useful
defaults" - i.e. show how to do /module/controller/action/ (which is
preffered setup in many cases) first and trying to "teach" how the routing
works after that - most people don't want to learn :) They want to make it
work :P Don't think there is really need for magic router (I'm not familiar
with the IRC talk mentioned), as long as the docs present useful defaults.

On Fri, Nov 25, 2011 at 7:31 AM, Simon Walter <[hidden email]> wrote:

> Hi all,
>
> I read over some of the IRC meeting log. I wanted to comment about the
> magic
> router idea. I don't know of anyone else who "stumbled" with this. I think
> I
> was the only one. So I feel I need to comment about this lest a bunch of
> work
> goes into making this magic router. Maybe it is needed. Though I think it's
> really down to the documentation and examples.
>
> That is where I was thrown off. After hearing the explanations and doing
> more
> reading, I'm able to get the routing structure I prefer:
> /module/controller/action
>
> It's not anything "magic", it just how the module config is defined among a
> few other things.
>
> Another thing I'd like to mention about the examples is that the
> "Application"
> module that comes with the ZendSkeletonApplication, IMHO, is much better
> suited to a module example over the ZendSkeletonModule. After having read
> through the "Application" module code, everything was much clearer. The
> ZendSkeletonModule relies too much on ZendSkeletonApplication's
> "Application"
> module so that one cannot see what is really going on. The documentation
> should really explain everything unless there is a "standard" module
> skeleton
> that perhaps Zend_Tool (Zend\Tool?) will output. The Quick Start is much
> too
> sparse and the resulting code did not work - it doesn't match what's in the
> repos and the ZF library included in ZendSkeletonApplication was not the
> same
> build (version) as HEAD. I worked through the errors and changed a lot of
> the
> example to get it to work as it said it should. Then was dis-satisfied with
> the routing.
>
> In order to save others the same issues, I suggest effort be put into the
> docs
> rather than a magic router, because, after all, the exact same result can
> be
> achieved with the performance improvements.
>
> Cheers,
>
> Simon
>
> Here is what my module.config.php looked after I got it set up how I liked
> it:
>
> <?php
> return array(
>    'bootstrap_class' => 'Test\Bootstrap',
>    'layout'          => 'layouts/layout.phtml',
>    'routes' => array(
>        'helloworld' => array(
>            'type'    => 'Zend\Mvc\Router\Http\Literal',
>            'options' => array(
>                'route' => '/helloworld',
>                'defaults' => array(
>                    'controller' => 'hello',
>                    'action'     => 'world',
>                ),
>            ),
>        ),
>        'default' => array(
>            'type'    => 'Zend\Mvc\Router\Http\Segment',
>            'options' => array(
>                'route'    => '/test[/:controller[/:action]]',
>                'constraints' => array(
>                    'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
>                    'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
>                ),
>                'defaults' => array(
>                    'controller' => 'index',
>                    'action'     => 'index',
>                ),
>            ),
>        ),
>    ),
>    'di' => array(
>        'instance' => array(
>            'alias' => array(
>                'hello' => 'Test\Controller\HelloController',
>                'view'  => 'Zend\View\PhpRenderer',
>            ),
>            'Zend\View\PhpRenderer' => array(
>                'parameters' => array(
>                    'resolver' => 'Zend\View\TemplatePathStack',
>                    'options'  => array(
>                        'script_paths' => array(
>                            'test' => __DIR__ . '/../views',
>                        ),
>                    ),
>                ),
>            ),
>        ),
>    ),
> );
>
>
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: magic router

EvanDotPro
In reply to this post by Simon Walter
On Thu, Nov 24, 2011 at 11:31 PM, Simon Walter <[hidden email]> wrote:

> Hi all,
>
> I read over some of the IRC meeting log. I wanted to comment about the
> magic
> router idea. I don't know of anyone else who "stumbled" with this. I think
> I
> was the only one. So I feel I need to comment about this lest a bunch of
> work
> goes into making this magic router. Maybe it is needed. Though I think it's
> really down to the documentation and examples.
>

Exactly. :)


That is where I was thrown off. After hearing the explanations and doing

> more
> reading, I'm able to get the routing structure I prefer:
> /module/controller/action
>
> It's not anything "magic", it just how the module config is defined among a
> few other things.
>
> Another thing I'd like to mention about the examples is that the
> "Application"
> module that comes with the ZendSkeletonApplication, IMHO, is much better
> suited to a module example over the ZendSkeletonModule. After having read
> through the "Application" module code, everything was much clearer. The
> ZendSkeletonModule relies too much on ZendSkeletonApplication's
> "Application"
> module so that one cannot see what is really going on. The documentation
> should really explain everything unless there is a "standard" module
> skeleton
> that perhaps Zend_Tool (Zend\Tool?) will output. The Quick Start is much
> too
> sparse and the resulting code did not work - it doesn't match what's in the
> repos and the ZF library included in ZendSkeletonApplication was not the
> same
> build (version) as HEAD. I worked through the errors and changed a lot of
> the
> example to get it to work as it said it should. Then was dis-satisfied with
> the routing.
>
> In order to save others the same issues, I suggest effort be put into the
> docs
> rather than a magic router, because, after all, the exact same result can
> be
> achieved with the performance improvements.
>

 At this point we're simply limited by our time to work on all of this
stuff. The router is pretty well documented. The module docs are due for
some updating; but again, it comes down to time and availability. We'll get
to it, but we'd also gladly accept PRs  for documentation. I also have
plans to add come comments and make the routes in the skeleton examples
more explicit when I have some time. If someone else has some time
available to do this, a PR is certainly welcome.

--
Evan Coury
Reply | Threaded
Open this post in threaded view
|

Re: magic router

weierophinney
Administrator
In reply to this post by Simon Walter
-- Simon Walter <[hidden email]> wrote
(on Thursday, 24 November 2011, 09:31 PM -0900):

> I read over some of the IRC meeting log. I wanted to comment about the magic
> router idea. I don't know of anyone else who "stumbled" with this. I think I
> was the only one. So I feel I need to comment about this lest a bunch of work
> goes into making this magic router. Maybe it is needed. Though I think it's
> really down to the documentation and examples.
>
> That is where I was thrown off. After hearing the explanations and doing more
> reading, I'm able to get the routing structure I prefer:
> /module/controller/action
>
> It's not anything "magic", it just how the module config is defined among a
> few other things.
>
> Another thing I'd like to mention about the examples is that the "Application"
> module that comes with the ZendSkeletonApplication, IMHO, is much better
> suited to a module example over the ZendSkeletonModule. After having read
> through the "Application" module code, everything was much clearer. The
> ZendSkeletonModule relies too much on ZendSkeletonApplication's "Application"
> module so that one cannot see what is really going on. The documentation
> should really explain everything unless there is a "standard" module skeleton
> that perhaps Zend_Tool (Zend\Tool?) will output. The Quick Start is much too
> sparse and the resulting code did not work - it doesn't match what's in the
> repos and the ZF library included in ZendSkeletonApplication was not the same
> build (version) as HEAD. I worked through the errors and changed a lot of the
> example to get it to work as it said it should. Then was dis-satisfied with
> the routing.

I just want to state one thing here: the docs and examples will always
lag behind the master repository until we're stable.

As such, if following the quick start, you should be following it for
the version it was released: beta2. Not master. beta2.

Next, please feel free to submit issues and/or patches to the
documentation and/or skeleton repos when you find issues. Reporting that
they "don't work" is fine, but we need to know exactly _what_ didn't
work, so they can be updated. This may be as trivial as "please update
the ZF2 git submodule in ZendSkeletonApplication to rXXXX or later."

> In order to save others the same issues, I suggest effort be put into
> the docs rather than a magic router, because, after all, the exact
> same result can be achieved with the performance improvements.

re: put effort into the docs instead of a magic router: I'm in
agreement.

> Cheers,
>
> Simon
>
> Here is what my module.config.php looked after I got it set up how I liked it:
>
> <?php
> return array(
>     'bootstrap_class' => 'Test\Bootstrap',
>     'layout'          => 'layouts/layout.phtml',
>     'routes' => array(
>         'helloworld' => array(
>             'type'    => 'Zend\Mvc\Router\Http\Literal',
>             'options' => array(
>                 'route' => '/helloworld',
>                 'defaults' => array(
>                     'controller' => 'hello',
>                     'action'     => 'world',
>                 ),
>             ),
>         ),
>         'default' => array(
>             'type'    => 'Zend\Mvc\Router\Http\Segment',
>             'options' => array(
>                 'route'    => '/test[/:controller[/:action]]',
>                 'constraints' => array(
>                     'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
>                     'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
>                 ),
>                 'defaults' => array(
>                     'controller' => 'index',
>                     'action'     => 'index',
>                 ),
>             ),
>         ),
>     ),
>     'di' => array(
>         'instance' => array(
>             'alias' => array(
>                 'hello' => 'Test\Controller\HelloController',
>                 'view'  => 'Zend\View\PhpRenderer',
>             ),
>             'Zend\View\PhpRenderer' => array(
>                 'parameters' => array(
>                     'resolver' => 'Zend\View\TemplatePathStack',
>                     'options'  => array(
>                         'script_paths' => array(
>                             'test' => __DIR__ . '/../views',
>                         ),
>                     ),
>                 ),
>             ),
>         ),
>     ),
> );
>
>
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: magic router

EvanDotPro
On Mon, Nov 28, 2011 at 7:35 AM, Matthew Weier O'Phinney
<[hidden email]> wrote:

> -- Simon Walter <[hidden email]> wrote
> (on Thursday, 24 November 2011, 09:31 PM -0900):
>> I read over some of the IRC meeting log. I wanted to comment about the magic
>> router idea. I don't know of anyone else who "stumbled" with this. I think I
>> was the only one. So I feel I need to comment about this lest a bunch of work
>> goes into making this magic router. Maybe it is needed. Though I think it's
>> really down to the documentation and examples.
>>
>> That is where I was thrown off. After hearing the explanations and doing more
>> reading, I'm able to get the routing structure I prefer:
>> /module/controller/action
>>
>> It's not anything "magic", it just how the module config is defined among a
>> few other things.
>>
>> Another thing I'd like to mention about the examples is that the "Application"
>> module that comes with the ZendSkeletonApplication, IMHO, is much better
>> suited to a module example over the ZendSkeletonModule. After having read
>> through the "Application" module code, everything was much clearer. The
>> ZendSkeletonModule relies too much on ZendSkeletonApplication's "Application"
>> module so that one cannot see what is really going on. The documentation
>> should really explain everything unless there is a "standard" module skeleton
>> that perhaps Zend_Tool (Zend\Tool?) will output. The Quick Start is much too
>> sparse and the resulting code did not work - it doesn't match what's in the
>> repos and the ZF library included in ZendSkeletonApplication was not the same
>> build (version) as HEAD. I worked through the errors and changed a lot of the
>> example to get it to work as it said it should. Then was dis-satisfied with
>> the routing.
>
> I just want to state one thing here: the docs and examples will always
> lag behind the master repository until we're stable.
>
> As such, if following the quick start, you should be following it for
> the version it was released: beta2. Not master. beta2.

Small correction: beta1, not beta2. :)

--
Evan Coury

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]