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条)

报告相同问题?

悬赏问题

  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?