Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Missing instance/object for parameter route upgrading to 2.1.* #3625

Closed
postalservice14 opened this issue Jan 31, 2013 · 20 comments · Fixed by #3640
Closed

Missing instance/object for parameter route upgrading to 2.1.* #3625

postalservice14 opened this issue Jan 31, 2013 · 20 comments · Fixed by #3640
Assignees
Milestone

Comments

@postalservice14
Copy link
Contributor

When I upgraded my application to 2.1.* I got the following exception on my home page:


( ! ) Fatal error: Uncaught exception 'Zend\Di\Exception\MissingPropertyException' with message 'Missing instance/object for parameter route for Zend\Mvc\Router\Http\Literal::__construct' in /home/johnk/Projects/MaterialChanges/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 749
( ! ) Zend\Di\Exception\MissingPropertyException: Missing instance/object for parameter route for Zend\Mvc\Router\Http\Literal::__construct in /home/johnk/Projects/MaterialChanges/vendor/zendframework/zendframework/library/Zend/Di/Di.php on line 699
Call Stack
#   Time    Memory  Function    Location
1   0.1058  126796  {main}( )   ../index.php:0
2   0.1200  222312  Zend\Mvc\Application::init( ??? )   ../index.php:12
3   0.2031  2466112 Zend\Mvc\Application->bootstrap( )  ../Application.php:240
4   0.2099  2615268 Zend\ServiceManager\ServiceManager->get( ???, ??? ) ../Application.php:140
5   0.2100  2615652 Zend\ServiceManager\ServiceManager->create( ??? )   ../ServiceManager.php:446
6   0.2100  2615680 Zend\ServiceManager\ServiceManager->createFromFactory( ???, ??? )   ../ServiceManager.php:499
7   0.2104  2621696 Zend\ServiceManager\ServiceManager->createServiceViaCallback( ???, ???, ??? )   ../ServiceManager.php:872
8   0.2105  2621912 call_user_func ( ???, ???, ???, ??? )   ../ServiceManager.php:742
9   0.2105  2621932 Zend\Mvc\Service\RouterFactory->createService( ???, ???, ??? )  ../ServiceManager.php:742
10  0.2137  2710792 Zend\Mvc\Router\SimpleRouteStack->addRoutes( ??? )  ../RouterFactory.php:60
11  0.2137  2711332 Zend\Mvc\Router\Http\TreeRouteStack->addRoute( ???, ???, ??? )  ../SimpleRouteStack.php:139
12  0.2137  2711388 Zend\Mvc\Router\Http\TreeRouteStack->routeFromArray( ??? )  ../TreeRouteStack.php:74
13  0.2137  2711484 Zend\Mvc\Router\SimpleRouteStack->routeFromArray( ??? ) ../TreeRouteStack.php:97
14  0.2137  2711556 Zend\ServiceManager\AbstractPluginManager->get( ???, ???, ??? ) ../SimpleRouteStack.php:273
15  0.2149  2725664 Zend\ServiceManager\ServiceManager->get( ???, ??? ) ../AbstractPluginManager.php:103
16  0.2150  2726100 Zend\ServiceManager\ServiceManager->create( ??? )   ../ServiceManager.php:446
17  0.2152  2726256 Zend\ServiceManager\ServiceManager->createFromAbstractFactory( ???, ??? )   ../ServiceManager.php:507
18  0.2153  2726852 Zend\ServiceManager\ServiceManager->createServiceViaCallback( ???, ???, ??? )   ../ServiceManager.php:913
19  0.2153  2727164 call_user_func ( ???, ???, ???, ??? )   ../ServiceManager.php:742
20  0.2153  2727184 Zend\ServiceManager\Di\DiAbstractServiceFactory->createServiceWithName( ???, ???, ??? ) ../ServiceManager.php:742
21  0.2153  2727328 Zend\ServiceManager\Di\DiServiceFactory->get( ???, ???, ??? )   ../DiAbstractServiceFactory.php:43
22  0.2154  2727456 Zend\Di\Di->get( ???, ??? ) ../DiServiceFactory.php:104
23  0.2182  2806792 Zend\Di\Di->newInstance( ???, ???, ??? )    ../Di.php:174
24  0.2193  2809616 Zend\Di\Di->createInstanceViaConstructor( ???, ???, ??? )   ../Di.php:225
25  0.2194  2809832 Zend\Di\Di->resolveMethodParameters( ???, ???, ???, ???, ???, ??? ) ../Di.php:393
( ! ) Zend\ServiceManager\Exception\ServiceNotCreatedException: An exception was raised while creating "Zend\Mvc\Router\Http\Literal"; no instance returned in /home/johnk/Projects/MaterialChanges/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 749
Call Stack
#   Time    Memory  Function    Location
1   0.1058  126796  {main}( )   ../index.php:0
2   0.1200  222312  Zend\Mvc\Application::init( ??? )   ../index.php:12
3   0.2031  2466112 Zend\Mvc\Application->bootstrap( )  ../Application.php:240
4   0.2099  2615268 Zend\ServiceManager\ServiceManager->get( ???, ??? ) ../Application.php:140
5   0.2100  2615652 Zend\ServiceManager\ServiceManager->create( ??? )   ../ServiceManager.php:446
6   0.2100  2615680 Zend\ServiceManager\ServiceManager->createFromFactory( ???, ??? )   ../ServiceManager.php:499
7   0.2104  2621696 Zend\ServiceManager\ServiceManager->createServiceViaCallback( ???, ???, ??? )   ../ServiceManager.php:872
8   0.2105  2621912 call_user_func ( ???, ???, ???, ??? )   ../ServiceManager.php:742
9   0.2105  2621932 Zend\Mvc\Service\RouterFactory->createService( ???, ???, ??? )  ../ServiceManager.php:742
10  0.2137  2710792 Zend\Mvc\Router\SimpleRouteStack->addRoutes( ??? )  ../RouterFactory.php:60
11  0.2137  2711332 Zend\Mvc\Router\Http\TreeRouteStack->addRoute( ???, ???, ??? )  ../SimpleRouteStack.php:139
12  0.2137  2711388 Zend\Mvc\Router\Http\TreeRouteStack->routeFromArray( ??? )  ../TreeRouteStack.php:74
13  0.2137  2711484 Zend\Mvc\Router\SimpleRouteStack->routeFromArray( ??? ) ../TreeRouteStack.php:97
14  0.2137  2711556 Zend\ServiceManager\AbstractPluginManager->get( ???, ???, ??? ) ../SimpleRouteStack.php:273
15  0.2149  2725664 Zend\ServiceManager\ServiceManager->get( ???, ??? ) ../AbstractPluginManager.php:103
16  0.2150  2726100 Zend\ServiceManager\ServiceManager->create( ??? )   ../ServiceManager.php:446
17  0.2152  2726256 Zend\ServiceManager\ServiceManager->createFromAbstractFactory( ???, ??? )   ../ServiceManager.php:507
18  0.2153  2726852 Zend\ServiceManager\ServiceManager->createServiceViaCallback( ???, ???, ??? )   ../ServiceManager.php:913
( ! ) Zend\ServiceManager\Exception\ServiceNotCreatedException: An abstract factory could not create an instance of zendmvcrouterhttpliteral(alias: Zend\Mvc\Router\Http\Literal). in /home/johnk/Projects/MaterialChanges/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 920
Call Stack
#   Time    Memory  Function    Location
1   0.1058  126796  {main}( )   ../index.php:0
2   0.1200  222312  Zend\Mvc\Application::init( ??? )   ../index.php:12
3   0.2031  2466112 Zend\Mvc\Application->bootstrap( )  ../Application.php:240
4   0.2099  2615268 Zend\ServiceManager\ServiceManager->get( ???, ??? ) ../Application.php:140
5   0.2100  2615652 Zend\ServiceManager\ServiceManager->create( ??? )   ../ServiceManager.php:446
6   0.2100  2615680 Zend\ServiceManager\ServiceManager->createFromFactory( ???, ??? )   ../ServiceManager.php:499
7   0.2104  2621696 Zend\ServiceManager\ServiceManager->createServiceViaCallback( ???, ???, ??? )   ../ServiceManager.php:872
8   0.2105  2621912 call_user_func ( ???, ???, ???, ??? )   ../ServiceManager.php:742
9   0.2105  2621932 Zend\Mvc\Service\RouterFactory->createService( ???, ???, ??? )  ../ServiceManager.php:742
10  0.2137  2710792 Zend\Mvc\Router\SimpleRouteStack->addRoutes( ??? )  ../RouterFactory.php:60
11  0.2137  2711332 Zend\Mvc\Router\Http\TreeRouteStack->addRoute( ???, ???, ??? )  ../SimpleRouteStack.php:139
12  0.2137  2711388 Zend\Mvc\Router\Http\TreeRouteStack->routeFromArray( ??? )  ../TreeRouteStack.php:74
13  0.2137  2711484 Zend\Mvc\Router\SimpleRouteStack->routeFromArray( ??? ) ../TreeRouteStack.php:97
14  0.2137  2711556 Zend\ServiceManager\AbstractPluginManager->get( ???, ???, ??? ) ../SimpleRouteStack.php:273
15  0.2149  2725664 Zend\ServiceManager\ServiceManager->get( ???, ??? ) ../AbstractPluginManager.php:103
16  0.2150  2726100 Zend\ServiceManager\ServiceManager->create( ??? )   ../ServiceManager.php:446
17  0.2152  2726256 Zend\ServiceManager\ServiceManager->createFromAbstractFactory( ???, ??? )   ../ServiceManager.php:507
( ! ) Zend\ServiceManager\Exception\ServiceNotCreatedException: An exception was raised while creating "Router"; no instance returned in /home/johnk/Projects/MaterialChanges/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 749
Call Stack
#   Time    Memory  Function    Location
1   0.1058  126796  {main}( )   ../index.php:0
2   0.1200  222312  Zend\Mvc\Application::init( ??? )   ../index.php:12
3   0.2031  2466112 Zend\Mvc\Application->bootstrap( )  ../Application.php:240
4   0.2099  2615268 Zend\ServiceManager\ServiceManager->get( ???, ??? ) ../Application.php:140
5   0.2100  2615652 Zend\ServiceManager\ServiceManager->create( ??? )   ../ServiceManager.php:446
6   0.2100  2615680 Zend\ServiceManager\ServiceManager->createFromFactory( ???, ??? )   ../ServiceManager.php:499
7   0.2104  2621696 Zend\ServiceManager\ServiceManager->createServiceViaCallback( ???, ???, ??? )   ../ServiceManager.php:872
@postalservice14
Copy link
Contributor Author

Note: downgrading to 2.0.7 makes my application work again. Weird. :-/

@weierophinney
Copy link
Member

Are you actually using Zend\Di in your application? If not, can you remove the config key for it and see if it works under 2.1.0? (Even if you are, try disabling it and accessing a route that does not use it.) Let me know what happens; if what I suspect is true, we'll need to create an FAQ for this.

@postalservice14
Copy link
Contributor Author

Weird, yes, you're right. Removing the 'di' section from my module config files allows my page to be viewable without the exception.

And yes, I am using Zend\Di.

I'd love to hear why this is....

@weierophinney
Copy link
Member

There are two changes in 2.1.0 that could affect this. One, from @bakura10 makes the router's plugin manager an app-level plugin manager (like view helpers, controller plugins, etc); this might end up in it peering off the app's service manag , which could cause the bleed-over.

The second change is that we eliminated the DI abstract factory as an initializer; @Ocramius might know if that would affect this.

Once we know which is causing this, we can likely come up with a workaround.

@Ocramius
Copy link
Member

@weierophinney the initializer acts after ServiceManager::createServiceViaCallback anyway

@Ocramius
Copy link
Member

Ah, btw, in 2.0 we didn't have the Di fallback. @postalservice14 are you able to provide parameters for this stack? What is the service being requested? What is the route configuration?

@alexz707
Copy link

I have the same problem, just upgraded and the server respons with a 500....
Error:

PHP Fatal error: Uncaught exception 'Zend\Di\Exception\MissingPropertyException' with message 'Missing instance/object for parameter route for Zend\Mvc\Router\Http\Literal::__construct' in /ucv/src/vendor/zendframework/zendframework/library/Zend/Di/Di.php:699\n

Stack trace:
NR:0 /ucv/src/vendor/zendframework/zendframework/library/Zend/Di/Di.php(393): Zend\Di\Di->resolveMethodParameters('Zend\Mvc\Router...', '__construct', Array, NULL, true, true)
NR:1 /ucv/src/vendor/zendframework/zendframework/library/Zend/Di/Di.php(225): Zend\Di\Di->createInstanceViaConstructor('Zend\Mvc\Router...', Array, NULL)
NR:2 /ucv/src/vendor/zendframework/zendframework/library/Zend/Di/Di.php(174): Zend\Di\Di->newInstance('Zend\Mvc\Router...', Array, true)
NR:3 /ucv/src/vendor/zendframework/zendframework/library/Zend/ServiceManager/Di/DiServiceFactory.php(104): Zend\Di\Di->get('Zend\Mvc\Router...', Array)
NR:4 /ucv/src/vendor/zendframework/zendframework/library/Zend/ServiceManager/Di/DiAbstractServiceFactory.php(43): Zend\ServiceManager\Di\DiServiceFactory->get( in /ucv/src/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 749

@Ocramius
Copy link
Member

@bakura10: currently on gprs... can you check if invokables come before
abstract factories in the route plugin manager? I am thinking that the
DiAbstractServiceFactory is hit before the $autoAddInvokables thing.
That would affect people with $config['di'] set
On Jan 31, 2013 2:00 PM, "alexz707" notifications@github.com wrote:

I have the same problem, just upgraded and the server respons with a
500....
Error:

PHP Fatal error: Uncaught exception
'Zend\Di\Exception\MissingPropertyException' with message 'Missing
instance/object for parameter route for
Zend\Mvc\Router\Http\Literal::__construct' in
/ucv/src/vendor/zendframework/zendframework/library/Zend/Di/Di.php:699\n

Stack trace:
#0
/ucv/src/vendor/zendframework/zendframework/library/Zend/Di/Di.php(393):
Zend\Di\Di->resolveMethodParameters('Zend\Mvc\Router...', '__construct',
Array, NULL, true, true)
#1 #1:
Zend\Di\Di->createInstanceViaConstructor('Zend\Mvc\Router...', Array, NULL)
#2 #2:
Zend\Di\Di->newInstance('Zend\Mvc\Router...', Array, true)
#3 #3:
Zend\Di\Di->get('Zend\Mvc\Router...', Array)
#4 #4:
Zend\ServiceManager\Di\DiServiceFactory->get( in
/ucv/src/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php
on line 749


Reply to this email directly or view it on GitHubhttps://github.com//issues/3625#issuecomment-12941254.

@Ocramius
Copy link
Member

@alexz707 please provide a dump of $sm->get('config') in a gist if
possible. Also, remember to strip any confodential data before pasting.
On Jan 31, 2013 2:00 PM, "alexz707" notifications@github.com wrote:

I have the same problem, just upgraded and the server respons with a
500....
Error:

PHP Fatal error: Uncaught exception
'Zend\Di\Exception\MissingPropertyException' with message 'Missing
instance/object for parameter route for
Zend\Mvc\Router\Http\Literal::__construct' in
/ucv/src/vendor/zendframework/zendframework/library/Zend/Di/Di.php:699\n

Stack trace:
#0
/ucv/src/vendor/zendframework/zendframework/library/Zend/Di/Di.php(393):
Zend\Di\Di->resolveMethodParameters('Zend\Mvc\Router...', '__construct',
Array, NULL, true, true)
#1 #1:
Zend\Di\Di->createInstanceViaConstructor('Zend\Mvc\Router...', Array, NULL)
#2 #2:
Zend\Di\Di->newInstance('Zend\Mvc\Router...', Array, true)
#3 #3:
Zend\Di\Di->get('Zend\Mvc\Router...', Array)
#4 #4:
Zend\ServiceManager\Di\DiServiceFactory->get( in
/ucv/src/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php
on line 749


Reply to this email directly or view it on GitHubhttps://github.com//issues/3625#issuecomment-12941254.

@bakura10
Copy link
Contributor

Mmh... Invokables always come before abstract factories. The route plugin manager is like any other plugin manager so it's invokables => factories => abstract factories.

@Ocramius
Copy link
Member

Yeah, but by default, invokables are added at runtime internally
On Jan 31, 2013 2:20 PM, "Michaël Gallego" notifications@github.com wrote:

Mmh... Invokables always come before abstract factories. The route plugin
manager is like any other plugin manager so it's invokables => factories =>
abstract factories.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3625#issuecomment-12941836.

@weierophinney
Copy link
Member

@postalservice14 We really need to see your route, DI, and SM configuration to better diagnose and track down the issue. Any chance you can give us a scrubbed version of it that reproduces the problem?

@weierophinney
Copy link
Member

@alexz707 -- same goes for you -- any configuration examples you can give us will help us resolve the issue.

@postalservice14
Copy link
Contributor Author

@weierophinney Sorry about the delay. Here you go.

module.config.php (excerpt)

'router' => array(
        'routes' => array(
            'home' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Index',
                        'action'     => 'index',
                    ),
                ),
            ),
            'disableHomeScreen' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/disable-home-screen',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Index',
                        'action'     => 'disable-home-screen',
                    ),
                ),
            ),
            'login' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/login',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Auth',
                        'action'     => 'login',
                    ),
                ),
            ),
            'logout' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/logout',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Auth',
                        'action'     => 'logout',
                    ),
                ),
            ),
            'settings' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/settings',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Settings',
                        'action'     => 'index',
                    ),
                ),
            ),
            'select-project' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/project/select',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Project',
                        'action'     => 'select',
                    ),
                ),
            ),
            'select-contract' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/contract/select',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Contract',
                        'action'     => 'select',
                    ),
                ),
            ),
            'process-contract' => array(
                'type' => 'Zend\Mvc\Router\Http\Segment',
                'options' => array(
                    'route'    => '/contract[/:contract_id]/process',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Contract',
                        'action'     => 'process',
                    ),
                ),
            ),
        ),
    ),
    'di'    => array(
        'instance'  => array(
            'Application\Controller\Plugin\UserAuthentication'  => array(
                'parameters' => array(
                    'authAdapter'   => 'Cmp\Authentication\Adapter',
                    'authService'   => 'Zend\Authentication\AuthenticationService'
                )
            ),
            'Zend\Mvc\Controller\PluginLoader' => array(
                'parameters' => array(
                    'map' => array(
                        'userAuthentication' => 'Application\Controller\Plugin\Authentication'
                    )
                )
            )
        )
    ),
    'service_manager' => array(
        'factories' => array(
            'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
            'Zend\Log'   => function($sm) {
                $log = new Zend\Log\Logger();
                $writer = new Zend\Log\Writer\Stream('./data/logs/php.log');
                $log->addWriter($writer);

                return $log;
            }
        )
    ),

Module.php (excerpt)

public function getServiceConfig()
    {
        return array(
            'factories' => array(
                'Application\Model\SettingsTable'   => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $table = new SettingsTable($dbAdapter);
                    return $table;
                }
            )
        );
    }

    public function getViewHelperConfig()
    {
        return array(
            'factories' => array(
                'userIdentity' => function ($sm) {
                    $viewHelper = new View\Helper\UserIdentity();
                    $viewHelper->setAuthService(new \Zend\Authentication\AuthenticationService());
                    return $viewHelper;
                },
                'settingsHelper' => function ($sm) {
                    $locator = $sm->getServiceLocator();
                    $projectTable = $locator->get('Application\Model\SettingsTable');
                    $viewHelper = new View\Helper\SettingsHelper();
                    $viewHelper->setSettingsTable($projectTable);
                    return $viewHelper;
                },
                'version' => function ($sm) {
                    $locator = $sm->getServiceLocator();
                    $config = $locator->get('config');
                    $viewHelper = new View\Helper\VersionHelper();
                    $viewHelper->setVersion($config['version']);
                    return $viewHelper;
                }
            )
        );
    }

@youngguns-nl
Copy link
Contributor

You can work around this bug by calling them by shortname instead of the FQDN.

<?php
'router' => array(
        'routes' => array(
            'home' => array(
                'type' => 'Literal',
                'options' => array(
                    'route'    => '/',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Index',
                        'action'     => 'index',
                    ),
                ),
            ),
etc...
?>

@postalservice14
Copy link
Contributor Author

@youngguns-nl thanks, I'll give that a try when I get home from work today.

@ghost ghost assigned weierophinney Jan 31, 2013
@weierophinney
Copy link
Member

I've got a working test case reproducing the issue now; trying to see how to resolve the issue.

@weierophinney
Copy link
Member

@postalservice14 and @alexz707 -- I've got a PR in (#3640) which both verifies and resolves the issue.

The workaround you can use until this is in the branch and/or in a release is to use the short route names instead of the fully qualified class names, as they do not trigger the issue.

The fix I made was to override setInvokableClass() in the router plugin manager to also call setAlias(), aliasing the FQCN to the service name. This keeps things symmetric, ensures that as we create new routes, we don't reintroduce the issue, and helps us skip usage of the DiAbstractServiceFactory for classes that are not intended to hit it.

@alexz707
Copy link

alexz707 commented Feb 1, 2013

Thanks for looking into it and sorry for the delay!
I'm not sure if I have understood your fix completly...

So when I use 'Literal' instead of 'Zend\Mvc\Router\Http\Literal' in my routes it should work again ?

If that's the fix it wont work with my configuration :(
I still get the same error....

what do you need from my config file?

return array(
    'controllers' => array(
        'invokables' => array(
            'Defaultpage\Controller\Index' => 'Defaultpage\Controller\IndexController',
        ),
    ),
    'router' => array(
        'routes' => array(
            'defaultpage' => array(
                'type'    => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    // Change this to something specific to your module
                    'route'    => '/',
                    'defaults' => array(
                        // Change this value to reflect the namespace in which
                        // the controllers for your module are found
                        '__NAMESPACE__' => 'Defaultpage\Controller',
                        'controller'    => 'Index',
                        'action'        => 'index',
                    ),
                ),
                //'may_terminate' => true,
            ),
        ),
    ),
    'service_manager' => array(
            'factories' => array(
                    'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
            ),
    ),
    'translator' => array(
            'locale' => 'en_US',
            'translation_file_patterns' => array(
                    array(
                            'type'     => 'gettext',
                            'base_dir' => __DIR__ . '/../language',
                            'pattern'  => '%s.mo',
                    ),
            ),
    ),
    'view_manager' => array(
            'display_not_found_reason' => true,
            'display_exceptions'       => true,
            'doctype'                  => 'HTML5',
            'not_found_template'       => 'error/404',
            'exception_template'       => 'error/index',
            'template_map' => array(
                    'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
                    'base/index/index'        => __DIR__ . '/../view/base/index/index.phtml',
                    'error/404'               => __DIR__ . '/../view/error/404.phtml',
                    'error/index'             => __DIR__ . '/../view/error/index.phtml',
            ),
            'template_path_stack' => array(
                    __DIR__ . '/../view',
            ),
    ),
);

thanks for your help
Regards

Alex

@weierophinney
Copy link
Member

@alexz707 I've added a test demonstrating that pulling by short name works. Additionally, I ran this test both with and without the change to setInvokableClass(); it ran fine both with and without the change.

In your configuration above, wherever you have a 'type' => 'Zend\Mvc\Router\Http\<whatever>', remove the Zend\Mvc\Router\Http\ namespace. It will work, both with and without the changes introduced by my patch (others have verified this, as have the tests from my patch). If you're still having issues, hunt through your modules and application configuration to see if there are any stray cases of fully qualified class names being used for route types.

Alternately, apply my patch to your working files.

weierophinney added a commit to weierophinney/zendframework that referenced this issue Feb 1, 2013
…nvokables

- Prior to this patch, if a route has been registered as an invokable,
  but the DiAbstractServiceFactory was also present, using the FQCN to
  retrieve the route would result in DI being invoked. In the case of
  the various shipped ZF routes, this was undesirable, as the factory
  method for these classes was intended for instantiation; usage if DI
  caused failures.
- This patch overrides the setInvokableClass() method of the router
  plugin manager such that it also calls setAlias() to alias the FQCN to
  the service name; this ensures that usage of the FQCN for a class
  already registered as an invokable will work properly.
weierophinney added a commit to weierophinney/zendframework that referenced this issue Feb 1, 2013
- Added test demonstrating routes may be pulled by short names. Ran this
  test both before and after the setInvokableClass() change; passed in
  both cases.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants