Zend Framework 的自动加载器问题

发布于 2024-08-23 14:49:14 字数 4404 浏览 7 评论 0原文

一切都在index.php

/* Define site root */
defined('DOCUMENT_ROOT') ? null : define('DOCUMENT_ROOT',realpath(dirname(__FILE__)));
defined('SITE_ROOT') ? null : define('SITE_ROOT',realpath(dirname(DOCUMENT_ROOT.'../')));


// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', SITE_ROOT . '/application');


$includePath[] = '.';
$includePath[] = SITE_ROOT . '/library';
$includePath[] = get_include_path();
$includePath = implode(PATH_SEPARATOR,$includePath);
set_include_path($includePath);

require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();

 /* Adding action helpers path */
 Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/controllers/helpers','Helper');

 $application->bootstrap()
    ->run();

收到这些错误以及更多捆绑 ZF 助手的错误路径,出了什么问题?

/* 设置表单及其元素的装饰器路径和前缀 / $form->addElementPrefixPath('Form', SITE_ROOT . '/library/form/decorators', 'decorator'); // 前缀、路径、类型 / 设置额外的验证器 */ $form->addElementPrefixPath('Form', SITE_ROOT . '/library/form/validators', 'validate'); // prefi、path、type

 [2] fopen(/var/www/vhosts/blabla.com/httpdocs/application/controllers/helpers/ViewRenderer.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/InArray.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/InArray.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/InArray.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/InArray.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 

与 ZF 验证器捆绑在一起位于此处:

例如library/Zend/Validate/InArray.php

那么自动加载器有什么问题呢?

it's all in index.php

/* Define site root */
defined('DOCUMENT_ROOT') ? null : define('DOCUMENT_ROOT',realpath(dirname(__FILE__)));
defined('SITE_ROOT') ? null : define('SITE_ROOT',realpath(dirname(DOCUMENT_ROOT.'../')));


// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', SITE_ROOT . '/application');


$includePath[] = '.';
$includePath[] = SITE_ROOT . '/library';
$includePath[] = get_include_path();
$includePath = implode(PATH_SEPARATOR,$includePath);
set_include_path($includePath);

require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();

 /* Adding action helpers path */
 Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/controllers/helpers','Helper');

 $application->bootstrap()
    ->run();

Getting those error and a lot more with wrong paths to bundled ZF helpers, what's wrong?

/* Setting decorators path and prefix for form and it's elements /
$form->addElementPrefixPath('Form', SITE_ROOT . '/library/form/decorators', 'decorator'); // prefix, path, type
/
Setting additional validators */
$form->addElementPrefixPath('Form', SITE_ROOT . '/library/form/validators', 'validate'); // prefi, path, type

 [2] fopen(/var/www/vhosts/blabla.com/httpdocs/application/controllers/helpers/ViewRenderer.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/InArray.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/InArray.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/InArray.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/InArray.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 
  [2] fopen(/var/www/vhosts/blabla.com/httpdocs/library/form/validators/NotEmpty.php) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory 
  in file: /var/www/vhosts/blabla.com/httpdocs/library/Zend/Loader.php 
  on line: 165 

Bundled with ZF validators are located here:

library/Zend/Validate/InArray.php for example

What's wrong with autoloader then?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷途知返 2024-08-30 14:49:14

defines 中删除realpath 并调试您定义的路径是否正确。

这似乎是连线的:

realpath(dirname(DOCUMENT_ROOT.'../'));

不应该是:

realpath(dirname(dirname(DOCUMENT_ROOT)')));

或者:

realpath(dirname(('/../'.DOCUMENT_ROOT)'));

另外,请仔细检查文件权限。

Remove realpath from the defines and debug the paths which you define are correct.

This seems wired:

realpath(dirname(DOCUMENT_ROOT.'../'));

shouldn't it be:

realpath(dirname(dirname(DOCUMENT_ROOT)')));

or:

realpath(dirname(('/../'.DOCUMENT_ROOT)'));

Also, double chceck the file permissions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文