Php ZF2 restservice获取错误

Php ZF2 restservice获取错误,php,zend-framework2,Php,Zend Framework2,如何访问出现错误“错误路由器不匹配”的rest服务 My Module.config return array( 'router' => array( 'routes' => array( 'services' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'rout

如何访问出现错误“错误路由器不匹配”的rest服务

My Module.config

return array(
'router' => array(
    'routes' => array(
        'services' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/services',
                'defaults' => array(
                    '__NAMESPACE__' => 'Restapi\Controller\restapi',
                ),
            ),
        ),            
        'services' => array(
            'type'    => 'segment',
            'may_terminate' => true,
            'options' => array(
                'route'    => '/services[/:id]',
                'constraints' => array(
                                        'id'=>'[0-9a-zA-Z]+',
                                      ),
                'defaults' => array(
                    'controller' => 'Restapi\Controller\rest',
                ),
            ),
        ),
    ),
),
'controllers' => array(
    'invokables' => array(
        'Restapi\Controller\Rest' => 'Restapi\Controller\RestapiController',            
    ),
),
'view_manager' => array(
    'strategies' => array(
        'ViewJsonStrategy`'`,
    ),
),

))

我看到您的路由设置无效。 首先:一个服务部分重写另一个服务部分。 您可以只设置默认值,因此不需要第一节服务。 第二部分没有合适的路由,它只能处理像

要接受服务/呼叫/登录路径必须是这样的

<?php

return array(
    'router'      => array(
        'routes' => array(
            'services' => array(
                'type'          => 'segment',
                'may_terminate' => true,
                'options'       => array(
                    'route'       => '/services[/[:controller[/:action]]]',
                    'constraints' => array('id' => '[0-9a-zA-Z]+',),
                    'defaults'    => array(
                        'controller' => 'Restapi\Controller\rest',
                        'action'     => 'index', // Default action for "/services" route
                    ),
                ),
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Restapi\Controller\Rest' => 'Restapi\Controller\RestapiController',
        ),
    ),
    'view_manager' => array(
        'strategies' => array(
            'ViewJsonStrategy',
        ),
    ),
);