Making a module default path

For programming and general questions on Zend Framework

Making a module default path

Postby ryanrk on Fri Dec 07, 2012 8:06 pm

So, I'm trying to make a module the default path. http://url/:controller/:action should link to Application/controller/action my routes in module.config.php looks like this but I can't figure why it's not working.
Code: Select all
'router' => array(
        'routes' => array(
            'home' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Index',
                        'action'     => 'index',
                    ),
                ),
            ),
            // The following is a route to simplify getting started creating
            // new controllers and actions without needing to create a new
            // module. Simply drop new controllers in, and you can access them
            // using the path /application/:controller/:action
            'application' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'    => '/application',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Application\Controller',
                        'controller'    => 'Index',
                        'action'        => 'index',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'default' => array(
                        'type'    => '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(
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),



Thanks!
ryanrk
 
Posts: 3
Joined: Fri Dec 07, 2012 8:01 pm

Re: Making a module default path

Postby perosurac on Sat Dec 08, 2012 11:34 am

Hi there,

I had the same problem a few days ago. My __NAMESPACE__ variable was empty, instead of having Application\Controller in it. Thus the IndexController was unfindable.
Maybe is it the same problem for you ...

Regards.
perosurac
 
Posts: 1
Joined: Sat Dec 08, 2012 11:30 am

Re: Making a module default path

Postby ryanrk on Wed Dec 12, 2012 9:21 pm

Yes, that was correct. I didn't have it set.
ryanrk
 
Posts: 3
Joined: Fri Dec 07, 2012 8:01 pm


Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 2 guests