Here is my zend framework module config:
'routes' => [
'home' => [
'type' => Literal::class,
'options' => [
'route' => '/',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],
'default' => array(
'type' => 'segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
'constraints' => [
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
]
),
)
...
'controllers' => [
'factories' => [
Controller\IndexController::class => InvokableFactory::class,
],
and my IndexController.php looks like this:
class IndexController extends AbstractActionController
{
public function indexAction()
{
return new ViewModel();
}
public function testAction()
{
echo 1;
return 1;
}
}
I want get a right response when I access http://host/Index/test
, but now I get a 404 error
and a description like:
"The requested controller could not be mapped to an existing controller class ...".
What's the problem?
尝试将'type' => 'segment'
更改为'type' => 'Segment'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.