Zend Framework 2树路由堆栈错误

时间:2016-12-19 15:36:47

标签: php zend-framework

我在module.config.php中遇到了我的子路由问题。我把它设置为主要路线可以接受儿童路线的地方(我以前做过这个并且从来没有遇到过这个问题)但是由于某种原因我收到了这个错误:

PHP Warning:  explode() expects parameter 2 to be string, array given in C:\\xampp\\htdocs\\vendor\\zendframework\\zend-mvc\\src\\Router\\Http\\TreeRouteStack.php on line 313

我一遍又一遍地看着它,但我看不出可能造成这种情况的原因。这是我在module.config.php中路由的代码(它只出现在/ setup页面上)

'router' => array(
    'routes' => array(
        'home' => array(
            'type'    => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Application\Controller\Index',
                    'action'     => 'index',
                ),
            ),

            'may_terminate' => true,
            'child_routes' => array(
                'default' => array(
                    'type'    => 'Segment',
                    'options' => array(
                        'route'       => '/[:controller[/:action]]',
                        'constraints' => array(
                            'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                            'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                        ),

                        'defaults' => array(

                        ),
                    ),
                ),

                'setup' => array(
                    'type'    => 'Segment',
                    'options' => array(
                        'route' => 'setup[/:action]',
                        'defaults' => array(
                            'controller' => 'Application\Controller\Setup',
                            'action'     => 'index',
                        ),
                    ),
                ),

                'admin-login' => array(
                    'type'    => 'Segment',
                    'options' => array(
                        'route' => 'admin-login[/:action]',
                        'defaults' => array(
                            'controller' => 'Application\Controller\AdminLogin',
                            'action'     => 'index',
                        ),
                    ),
                ),

                'member-login' => array(
                    'type'    => 'Segment',
                    'options' => array(
                        'route' => 'member-login[/:action]',
                        'defaults' => array(
                            'controller' => 'Application\Controller\MemberLogin',
                            'action'     => 'index',
                        ),
                    ),
                ),

                'logout' => array(
                    'type'    => 'Literal',
                    'options' => array(
                        'route' => 'logout',
                        'defaults' => array(
                            'controller' => 'Application\Controller\Logout',
                            'action'     => 'index',
                        ),
                    ),
                ),

                'register' => array(
                    'type'    => 'Segment',
                    'options' => array(
                        'route' => 'register[/:action]',
                        'defaults' => array(
                            'controller' => 'Application\Controller\Register',
                            'action'     => 'index',
                        ),
                    ),
                ),

                'verify' => array(
                    'type'    => 'Segment',
                    'options' => array(
                        'route' => 'verify[/:code]',
                        'constraints' => array(
                            'code' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        ),

                        'defaults' => array(
                            'controller' => 'Application\Controller\Verify',
                            'action'     => 'index',
                        ),
                    ),
                ),
            ),
        ),
    ),
),

如果这不是足够的信息我很抱歉,但我不确定如何完全描述这一点。我在页面上是主页/设置路径(设置)但是再一次,我收到有关explode()的警告。

我不知道这是否相关,但这是我的观点:

<div class="w3-row">
<div class="w3-col w3-container m8 l9">
<?php
    $this->form->setAttribute('action', $this->url(array(
        'home/setup', array('action' => 'index'),
    )));

    $this->form->prepare();


    echo $this->form()->openTag($this->form);
?>

<?php
      $username = $this->form->get('username');

      $password = $this->form->get('password');



      echo $this->formRow($username);

      echo $this->formRow($password);

      echo $this->formElement($this->form->get('csrf_security'));

      echo $this->formElement($this->form->get('submit'));

      echo $this->form()->closeTag();
?>
</div>

谢谢!

1 个答案:

答案 0 :(得分:0)

我明白了,我在视图中设置了错误的$ this-&gt; url。