我想在zendframework中添加一个图像处理类,通过手册上还有网上看到的一些方法,都是报错,不知道什么原因?
我把imageprocessing.php放在application\controller\plugin目录下,
内容
class custom_controller_plugin_imageprocessing extends zend_controller_plugin_abstract{
……
}
然后在textaction()中使用,zend_loader::loadclass('custom_controller_plugin_imageprocessing');
报错:
assembly codefatal error: uncaught exception 'zend_controller_dispatcher_exception' with message 'invalid controller specified (error)' in f:\web\my\library\zend\controller\dispatcher\standard.php:248 stack trace: #0 f:\web\my\library\zend\controller\front.php(954): zend_controller_dispatcher_standard->dispatch(object(zend_controller_request_http), object(zend_controller_response_http)) #1 f:\web\my\index.php(28): zend_controller_front->dispatch() #2 {main} next exception 'zend_controller_exception' with message 'invalid controller specified (error)#0 f:\web\my\library\zend\controller\front.php(954): zend_controller_dispatcher_standard->dispatch(object(zend_controller_request_http), object(zend_controller_response_http)) #1 f:\web\my\index.php(28): zend_controller_front->dispatch() #2 {main}' in f:\web\my\library\zend\controller\plugin\broker.php:336 stack trace: #0 f:\web\my\library\zend\controller\front.php(965): zend_controller_plugin_broker->postdispatch(object(zend_controller_request_http)) #1 f:\web\my\index.php(28): zend_contr in f:\web\my\library\zend\controller\plugin\broker.php on line 336
这是按照网上别人说着的方法来做的,是不是我自己在controller目录下建立plugin文件夹,之后还要在哪里set一下plugin的路径?
index.php文件代码:
php codesetfallbackautoloader(true); //静态载入自动类文件 $registry = zend_registry::getinstance(); $view = new zend_view(); $view->setscriptpath('./tpl/');//设置模板显示路径// $view->sethelperpath('./tpl/');//设置 显示路径 $registry['view'] = $view;//注册view //配置数据库参数,并连接数据库 $config=new zend_config_ini('./application/config/config.ini',null, true); zend_registry::set('config',$config); $dbadapter=zend_db::factory($config->general->db->adapter,$config->general->db->config->toarray()); $dbadapter->query('set names utf8'); zend_db_table::setdefaultadapter($dbadapter); zend_registry::set('dbadapter',$dbadapter); zend_registry::set('dbprefix',$config->general->db->config->prefix); //设置控制器 $frontcontroller =zend_controller_front::getinstance(); $frontcontroller->setbaseurl('/')//设置基本路径 ->setparam('noviewrenderer', true) ->setcontrollerdirectory('./application/controller') ->dispatch();// ->throwexceptions(true)
还有我把该类放到application\views\helpers目录下,
内容:class zend_view_helper_imageprocessing extends zend_view_helper_abstract {……}
也报一样的错误。
这个问题搞了好几天了,希望高手帮帮我。
还有个小问题,就是在thinkphp中,如果要添加自己公共function,可以在common/common.php中添加,而zendframework是通过怎么添加?
------解决方案--------------------
要不可以用这个,但是有点牵强
http://blog.csdn.net/mengxiangbaidu/article/details/7345108
那个\views\helpers自定义助手的方法。没有写。过两天有时间再写。
或者你直接include。这都是允许的
