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

While attempting to create httproutenotfoundstrategy #311

Open
voltan opened this issue Mar 23, 2019 · 1 comment
Open

While attempting to create httproutenotfoundstrategy #311

voltan opened this issue Mar 23, 2019 · 1 comment

Comments

@voltan
Copy link

voltan commented Mar 23, 2019

Hello

We have custom system based on zf2, when I update zend-mvc to version 2.7.15 , I have this error :

[err] #1096 in vendor/zendframework/zend-servicemanager/src/ServiceManager.php
While attempting to create httproutenotfoundstrategy(alias: HttpRouteNotFoundStrategy) an invalid factory was registered for this instance type.

we have custom config fro load all (( Default mvc-related service configuration )), I do some changes on my config file and all new options like MiddlewareListener and ..

But we have problem and error on loading HttpRouteNotFoundStrategy and HttpExceptionStrategy and HttpDefaultRenderingStrategy

My custom config is :

return [
    // ServiceMananger configuration
    'service_manager'    => [
        'aliases'            => [
            'configuration'                              => 'config',
            'Configuration'                              => 'config',
            'console'                                    => 'ConsoleAdapter',
            'Console'                                    => 'ConsoleAdapter',
            'ConsoleDefaultRenderingStrategy'            => View\Console\DefaultRenderingStrategy::class,
            'ControllerLoader'                           => 'ControllerManager',
            'Di'                                         => 'DependencyInjector',
            'HttpDefaultRenderingStrategy'               => View\Http\DefaultRenderingStrategy::class,
            //'MiddlewareListener'                       => 'Zend\Mvc\MiddlewareListener',
            //'RouteListener'                            => 'Zend\Mvc\RouteListener',
            //'SendResponseListener'                     => 'Zend\Mvc\SendResponseListener',
            'View'                                       => 'Zend\View\View',
            'ViewFeedRenderer'                           => 'Zend\View\Renderer\FeedRenderer',
            'ViewJsonRenderer'                           => 'Zend\View\Renderer\JsonRenderer',
            'ViewPhpRendererStrategy'                    => 'Zend\View\Strategy\PhpRendererStrategy',
            'ViewPhpRenderer'                            => 'Zend\View\Renderer\PhpRenderer',
            'ViewRenderer'                               => 'Zend\View\Renderer\PhpRenderer',
            'Zend\Di\LocatorInterface'                   => 'DependencyInjector',
            'Zend\Form\Annotation\FormAnnotationBuilder' => 'FormAnnotationBuilder',
            'Zend\Mvc\Controller\PluginManager'          => 'ControllerPluginManager',
            'Zend\Mvc\View\Http\InjectTemplateListener'  => 'InjectTemplateListener',
            'Zend\View\Renderer\RendererInterface'       => 'Zend\View\Renderer\PhpRenderer',
            'Zend\View\Resolver\TemplateMapResolver'     => 'ViewTemplateMapResolver',
            'Zend\View\Resolver\TemplatePathStack'       => 'ViewTemplatePathStack',
            'Zend\View\Resolver\AggregateResolver'       => 'ViewResolver',
            'Zend\View\Resolver\ResolverInterface'       => 'ViewResolver',
        ],
        'invokables'         => [
            'SharedEventManager'   => 'Zend\EventManager\SharedEventManager',

            // From ServiceListenerFactory
            //'DispatchListener'   => 'Zend\Mvc\DispatchListener',
            'RouteListener'        => 'Zend\Mvc\RouteListener',
            'MiddlewareListener'   => 'Zend\Mvc\MiddlewareListener',
            'ViewJsonRenderer'     => 'Zend\View\Renderer\JsonRenderer',
            'ViewFeedRenderer'     => 'Zend\View\Renderer\FeedRenderer',

            // Pi custom service
            'SendResponseListener' => 'Pi\Mvc\SendResponseListener',
            'ViewHelperManager'    => 'Pi\Mvc\Service\ViewHelperManager',
            'Config'               => 'Pi\Mvc\Service\Config',
            'ErrorStrategy'        => 'Pi\Mvc\View\Http\ErrorStrategy',
            'ViewStrategyListener' => 'Pi\Mvc\View\Http\ViewStrategyListener',
            'FeedStrategyListener' => 'Pi\Mvc\View\Http\FeedStrategyListener',
            'ApiStrategyListener'  => 'Pi\Mvc\View\Http\ApiStrategyListener',
        ],
        'factories'          => [
            'Application'                                => ApplicationFactory::class,
            //'config'                                   => 'Zend\Mvc\Service\ConfigFactory',
            'ControllerManager'                          => 'Zend\Mvc\Service\ControllerManagerFactory',
            //'ControllerPluginManager'                  => 'Zend\Mvc\Service\ControllerPluginManagerFactory',
            'ConsoleAdapter'                             => 'Zend\Mvc\Service\ConsoleAdapterFactory',
            'ConsoleExceptionStrategy'                   => ConsoleExceptionStrategyFactory::class,
            'ConsoleRouter'                              => ConsoleRouterFactory::class,
            'ConsoleRouteNotFoundStrategy'               => ConsoleRouteNotFoundStrategyFactory::class,
            'ConsoleViewManager'                         => 'Zend\Mvc\Service\ConsoleViewManagerFactory',
            'DependencyInjector'                         => DiFactory::class,
            'DiAbstractServiceFactory'                   => DiAbstractServiceFactoryFactory::class,
            'DiServiceInitializer'                       => DiServiceInitializerFactory::class,
            'DiStrictAbstractServiceFactory'             => DiStrictAbstractServiceFactoryFactory::class,
            'DispatchListener'                           => 'Zend\Mvc\Service\DispatchListenerFactory',
            'FilterManager'                              => 'Zend\Mvc\Service\FilterManagerFactory',
            'FormAnnotationBuilder'                      => 'Zend\Mvc\Service\FormAnnotationBuilderFactory',
            'FormElementManager'                         => 'Zend\Mvc\Service\FormElementManagerFactory',
            'HttpExceptionStrategy'                      => HttpExceptionStrategyFactory::class,
            'HttpMethodListener'                         => 'Zend\Mvc\Service\HttpMethodListenerFactory',
            'HttpRouteNotFoundStrategy'                  => HttpRouteNotFoundStrategyFactory::class,
            'HttpRouter'                                 => HttpRouterFactory::class,
            'HttpViewManager'                            => 'Zend\Mvc\Service\HttpViewManagerFactory',
            'HydratorManager'                            => 'Zend\Mvc\Service\HydratorManagerFactory',
            'InjectTemplateListener'                     => 'Zend\Mvc\Service\InjectTemplateListenerFactory',
            'InputFilterManager'                         => 'Zend\Mvc\Service\InputFilterManagerFactory',
            'LogProcessorManager'                        => 'Zend\Mvc\Service\LogProcessorManagerFactory',
            'LogWriterManager'                           => 'Zend\Mvc\Service\LogWriterManagerFactory',
            //'MvcTranslator'                            => 'Zend\Mvc\Service\TranslatorServiceFactory',
            'PaginatorPluginManager'                     => 'Zend\Mvc\Service\PaginatorPluginManagerFactory',
            'Request'                                    => 'Zend\Mvc\Service\RequestFactory',
            'Response'                                   => 'Zend\Mvc\Service\ResponseFactory',
            //'Router'                                   => 'Zend\Mvc\Service\RouterFactory',
            'RoutePluginManager'                         => 'Zend\Mvc\Service\RoutePluginManagerFactory',
            'SerializerAdapterManager'                   => 'Zend\Mvc\Service\SerializerAdapterPluginManagerFactory',
            'TranslatorPluginManager'                    => 'Zend\Mvc\Service\TranslatorPluginManagerFactory',
            'ValidatorManager'                           => 'Zend\Mvc\Service\ValidatorManagerFactory',
            View\Console\DefaultRenderingStrategy::class => InvokableFactory::class,
            //'ViewHelperManager'                        => 'Zend\Mvc\Service\ViewHelperManagerFactory',
            View\Http\DefaultRenderingStrategy::class    => HttpDefaultRenderingStrategyFactory::class,
            'ViewFeedStrategy'                           => 'Zend\Mvc\Service\ViewFeedStrategyFactory',
            'ViewJsonStrategy'                           => 'Zend\Mvc\Service\ViewJsonStrategyFactory',
            'ViewManager'                                => 'Zend\Mvc\Service\ViewManagerFactory',
            //'ViewResolver'                             => 'Zend\Mvc\Service\ViewResolverFactory',
            'ViewTemplateMapResolver'                    => 'Zend\Mvc\Service\ViewTemplateMapResolverFactory',
            'ViewTemplatePathStack'                      => 'Zend\Mvc\Service\ViewTemplatePathStackFactory',
            'ViewPrefixPathStackResolver'                => 'Zend\Mvc\Service\ViewPrefixPathStackResolverFactory',
            'Zend\Mvc\MiddlewareListener'                => InvokableFactory::class,
            'Zend\Mvc\RouteListener'                     => InvokableFactory::class,
            'Zend\Mvc\SendResponseListener'              => InvokableFactory::class,
            'Zend\View\Renderer\FeedRenderer'            => InvokableFactory::class,
            'Zend\View\Renderer\JsonRenderer'            => InvokableFactory::class,
            'Zend\View\Renderer\PhpRenderer'             => ViewPhpRendererFactory::class,
            'Zend\View\Strategy\PhpRendererStrategy'     => ViewPhpRendererStrategyFactory::class,
            'Zend\View\View'                             => ViewFactory::class,

            // Pi custom service
            'Application'                                => 'Pi\Mvc\Service\ApplicationFactory',
            'ControllerLoader'                           => 'Pi\Mvc\Service\ControllerLoaderFactory',
            'ControllerPluginManager'                    => 'Pi\Mvc\Service\ControllerPluginManagerFactory',
            'MvcTranslator'                              => 'Pi\Mvc\Service\TranslatorServiceFactory',
            'ViewResolver'                               => 'Pi\Mvc\Service\ViewResolverFactory',
        ],
        'abstract_factories' => [
            'Zend\Form\FormAbstractServiceFactory',
        ],
    ],

    // Listeners to be registered on Application::bootstrap
    'listeners'          => [
        'ViewStrategyListener',
    ],

    // ViewManager configuration
    'view_manager'       => [
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'not_found_template'       => 'error-404',
        'exception_template'       => 'error',
        'error_template'           => 'error',
        'denied_template'          => 'error-denied',
        'layout'                   => 'layout-front',
        'layout_error'             => 'layout-simple',
        'layout_ajax'              => 'layout-content',

        'mvc_strategies' => [
            'ErrorStrategy',
        ],

        'strategies' => [
            'ViewJsonStrategy',
        ],
    ],

    // ViewHelper config placeholder
    'view_helper_config' => [],

    // Response sender config
    'send_response'      => [
        // Compression for response
        // By enabling response compression, bandwidth and response time can be decreased but CPU utilization will be increased
        // If compress is needed, it is highly recommended to enable it through web server
        // Or enable `zlib.output_compression` in php.ini
        // @see https://gist.github.com/taiwen/c077ba2c8a33356d8815 for instruction

        // Just in case compression is not enabled by web server or by PHP, specify following specs
        // @note PHP `zlib` extension is required
        'compress' => false,
    ],
];

Do you have any idea ?

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-mvc; a new issue has been opened at laminas/laminas-mvc#6.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants