Quantcast

zf2 routes

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

zf2 routes

bestxp
This post has NOT been accepted by the mailing list yet.
Good evening, recently decided to get acquainted with zf, and immediately above privacy with the new version 2.

The question arose in the configuration module of the skeleton, there is a time

'routes' => array (
                         'default' => array (
                             'type' => 'Zend \ Mvc \ Router \ Http \ Segment',
                             'options' => array (
                                 'route' => '/ [: controller [/: action]]',
                                 'constraints' => array (
                                     'controller' => '[a-zA-Z] [a-zA-Z0-9_-] *',
                                     'action' => '[a-zA-Z] [a-zA-Z0-9_-] *',
                                 )
                                 'defaults' => array (
                                     'controller' => 'Application \ Controller \ IndexController',
                                     'action' => 'index',
                                 )
                             )
Set like a autoroute, but after the creation of Application \ Controller \ TestController, the transition http://localhost/test, get a 404 error may be somewhere I did not notice the config
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: zf2 routes

Marco Pivetta
That is because you have to specify an alias for the new controller:

'alias' => array(
    'test' => 'My\Test\Controller',
),

That will allow access to the controller via "/test" :)

Marco Pivetta

http://twitter.com/Ocramius     

http://marco-pivetta.com    



On 4 March 2012 18:10, bestxp [via Zend Framework Community] <[hidden email]> wrote:
Good evening, recently decided to get acquainted with zf, and immediately above privacy with the new version 2.

The question arose in the configuration module of the skeleton, there is a time

'routes' => array (
                         'default' => array (
                             'type' => 'Zend \ Mvc \ Router \ Http \ Segment',
                             'options' => array (
                                 'route' => '/ [: controller [/: action]]',
                                 'constraints' => array (
                                     'controller' => '[a-zA-Z] [a-zA-Z0-9_-] *',
                                     'action' => '[a-zA-Z] [a-zA-Z0-9_-] *',
                                 )
                                 'defaults' => array (
                                     'controller' => 'Application \ Controller \ IndexController',
                                     'action' => 'index',
                                 )
                             )
Set like a autoroute, but after the creation of Application \ Controller \ TestController, the transition http://localhost/test, get a 404 error may be somewhere I did not notice the config


If you reply to this email, your message will be added to the discussion below:
http://zend-framework-community.634137.n4.nabble.com/zf2-routes-tp4443808p4443808.html
To unsubscribe from Zend Framework Community, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: zf2 routes

bestxp
test the controller was presented as an example, I mean that would be no point controllers in the config file, and they were taken automatically based on the routes, such as / test / test => TestController (testAction), though I have not pointed out, this is called autoroute
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: zf2 routes

Marco Pivetta
Routing doesn't know anything about your controllers, it just produces
output parameters.
These are reused in Zend\Mvc\Application to decide what object to dispatch
(
https://github.com/zendframework/zf2/blob/master/library/Zend/Mvc/Application.php#L328).
Then, Zend\Mvc\Application tries to pull a controller from the service
locator.
There is no such thing as auto-discovery of controllers as controllers are
on different namespaces and modules.
What you can do is mapping some aliases to your controllers:

'home' => 'My\HomeController',
'other' => 'My\OtherController',
// etc...

Or inject your custom router.

Marco Pivetta

http://twitter.com/Ocramius

http://marco-pivetta.com



On 4 March 2012 19:09, bestxp <[hidden email]> wrote:

> test the controller was presented as an example, I mean that would be no
> point controllers in the config file, and they were taken automatically
> based on the routes, such as / test / test => TestController (testAction),
> though I have not pointed out, this is called autoroute
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/zf2-routes-tp4443808p4443928.html
> Sent from the Zend MVC mailing list archive at Nabble.com.
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: zf2 routes

bestxp
In reply to this post by bestxp
and as well as poluchaetsya that I need to be set in each path configuration

that is, for / test / test / test / index / test/test2
Although I have a controller test, and test index test2 is his method?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: zf2 routes

bestxp
This post has NOT been accepted by the mailing list yet.
Kind of like figured out, sometimes a little inconvenient, each controller to prescribe by Alias,
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: zf2 routes

weierophinney
Administrator
In reply to this post by Marco Pivetta
-- Marco Pivetta <[hidden email]> wrote
(on Sunday, 04 March 2012, 09:15 AM -0800):
> That is because you have to specify an alias for the new controller:
>
> 'alias' => array(
>     'test' => 'My\Test\Controller',
> ),
>
> That will allow access to the controller via "/test" :)

I'd recommend against using aliases, actually -- especially as of
ZF2beta3, they're largely unnecessary. The original reason we were using
aliases for controllers was to make finding the view scripts easier --
and this is no longer really a problem with the new view layer.


> On 4 March 2012 18:10, bestxp [via Zend Framework Community] <
> [hidden email]> wrote:
>
> > Good evening, recently decided to get acquainted with zf, and immediately
> > above privacy with the new version 2.
> >
> > The question arose in the configuration module of the skeleton, there is a
> > time
> >
> > 'routes' => array (
> >                          'default' => array (
> >                              'type' => 'Zend \ Mvc \ Router \ Http \ Segment',
> >                              'options' => array (
> >                                  'route' => '/ [: controller [/: action]]',
> >                                  'constraints' => array (
> >                                      'controller' => '[a-zA-Z] [a-zA-Z0-9_-] *',
> >                                      'action' => '[a-zA-Z] [a-zA-Z0-9_-] *',
> >                                  )
> >                                  'defaults' => array (
> >                                      'controller' => 'Application \ Controller \ IndexController',
> >                                      'action' => 'index',
> >                                  )
> >                              )
> >
> > Set like a autoroute, but after the creation of Application \ Controller \
> > TestController, the transition http://localhost/test, get a 404 error may
> > be somewhere I did not notice the config
> >
> > ------------------------------
> >  If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> > .
> > NAML<
http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
> >
>
>
> --
> View this message in context: http://zend-framework-community.634137.n4.nabble.com/zf2-routes-tp4443808p4443820.html
> Sent from the Zend MVC mailing list archive at Nabble.com.

--
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
|  
Report Content as Inappropriate
star

Re: zf2 routes

drj201
This post has NOT been accepted by the mailing list yet.
How would you do this without the use of Alias?

Thanks,

David
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: zf2 routes

Marco Pivetta
You would probably map a new route segment for each controller, or plug in a custom route segment that uses inflection to define the controller FQCN.
Another thing I'm thinking of is a Module that could use Doctrine\Common annotations to build routes, which is practically what Symfony2 already does.

Marco Pivetta

http://twitter.com/Ocramius     

http://marco-pivetta.com    



On 12 March 2012 11:59, drj201 [via Zend Framework Community] <[hidden email]> wrote:
How would you do this without the use of Alias?

Thanks,

David


If you reply to this email, your message will be added to the discussion below:
http://zend-framework-community.634137.n4.nabble.com/zf2-routes-tp4443808p4465788.html
To unsubscribe from Zend Framework Community, click here.
NAML

Loading...