douzhuo3233 2014-06-23 18:32
浏览 40
已采纳

zf2跨模块查看助手

I created a helper in the application module, and it works perfectly. When I try to load it from another modules, such as user, it tells me that it can not find the class.

Class 'Application \ View \ Helper \ Footertable' not found

I tried to put this code in module.config.php well as the application module even in the same file of the user module.

'view_helpers' => array (
    'invokables' => array (
    'footertable' => 'Application\View\Helper\Footertable' 
    ) 
), 

I think it's a problem autoloading class but I can not find information on how to load this helper when you are in another module

I invoke helper in view file using

$this->footertable()

work perfectly in application module but not in user module

any idea?

Hello, but my code is correct

<?php

namespace Application\View\Helper;

use Zend\View\Helper\AbstractHelper;

class Footertable extends AbstractHelper{
    protected  $inizioFine;
    protected  $numero;

    public function __invoke($inizioFine,$numero){
        $this->inizioFine = $inizioFine;
        $this->numero = $numero;
        echo  sprintf('Mostra %d a %d di %d record',$this->inizioFine['start'],$this->inizioFine['end'],$this->numero);
    }
}

the space in config is an copy & past errors. I still have the same problem: can't load helper from another module

update full error

Fatal error: Class 'Application\View\Helper\Footertable' not found in D:\www\httpdocs\test\vendor\zendframework\zendframework\library\Zend\ServiceManager\AbstractPluginManager.php on line 170

path is

D:\www\httpdocs\test\module\Application\src\View\Helper\Footertable.php
  • 写回答

2条回答 默认 最新

  • dongzhuxun5136 2014-06-26 20:46
    关注

    The path you posted doesn't look right. All the files in src for your Application module should be inside a folder called Application, since that's your top level namespace. So the path should be:

    D:\www\httpdocs\test\module\Application\src\Application\View\Helper\Footertable.php

    That would explain why the helper can't be autoloaded, but I don't understand how it works in the application module if this is the case.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证