Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While attempting to create httproutenotfoundstrategy #6

Closed
weierophinney opened this issue Dec 31, 2019 · 1 comment
Closed

While attempting to create httproutenotfoundstrategy #6

weierophinney opened this issue Dec 31, 2019 · 1 comment

Comments

@weierophinney
Copy link
Member

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 ?


Originally posted by @voltan at zendframework/zend-mvc#311

@alexmerlin
Copy link
Member

Closing issue due to being inactive for more than 1 year.

@alexmerlin alexmerlin closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants