douquan1953 2016-06-08 20:41
浏览 26
已采纳

Zend框架模块设置

I'm trying to setup a module in the Zend Framework. Right now all I want is for it to go to my summary.phtml page, which will display Hello World.
I have setup the directory structure under my module directory as follows:

Directory Structure

My files are as follows:

module.config.php

<?php
return array(
        'controllers' => array(
                'invokables' => array(
                        'BlindQC\Controller\BlindQC' => 'BlindQC\Controller\BlindQCController',
                ),
        ),
        // The following section is new and should be added to your file
        'router' => array(
                'routes' => array(
                        'blinqc' => array(
                                'type' => 'Literal',
                                'options' => array(
                                        'route' => '/summary',
                                        'defaults' => array(
                                                '__NAMESPACE__' => 'BlindQC\Controller',
                                                'controller' => 'BlindQC',
                                                'action' => 'summary',
                                        ),
                                ),
                        ),
                ),
        ),
        'view_manager' => array(
                'template_path_stack' => array(
                        'blindqc' => __DIR__ . '/../view',
                ),
        ),
);

BlindQCController.php

<?php
namespace BlindQC\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class BlindQCController extends AbstractActionController{
    public function summaryAction(){

    }
}; 

summary.phtml

<h1>Hello World</h1>

autoload_classmap.php

<?php
return array();

Module.php

<?php
namespace BlindQC;

class Module {
    public function getAutoloaderConfig() {
        return array(
                'Zend\Loader\ClassMapAutoloader' => array(__DIR__ . '/autoload_classmap.php',),
                'Zend\Loader\StandardAutoloader' => array(
                        'namespaces' => array(__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,),
                ),
        );
    }

    public function getConfig() {
        return include __DIR__ . '/config/module.config.php';
    }
}

I also modified my project's application.config.php to include my module:

// This should be an array of module namespaces used in the application.
'modules' => array(
        'Application',
        'UIExperiment',
        'Developer',
        'User',
        'Project',
        'Report',
        'ProjectFamily', 
        'FMEProcessManager', 
        'BlindQC'
),

When I try to go to the summary route (/blindqc/summary) I get a 404. Any idea what I'm doing wrong?

  • 写回答

1条回答 默认 最新

  • dongle2627 2016-06-08 20:48
    关注

    All I had to do was change the route in module.config.php to /blindqc/summary and rename view/blindqc/blindqc to view/blind-qc/blind-qc in my directory structure.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?