简体   繁体   English

如何在现有项目中加载Zend Framework?

[英]How to load the Zend Framework in my existing project?

I'm trying to add Zend to an existing project, and for this I guess I need the autoloader. 我正在尝试将Zend添加到现有项目中,为此,我想我需要自动加载器。 So I tried including various files in the Loader folder and running the register() method from them; 因此,我尝试将各种文件包含在Loader文件夹中,并从中运行register()方法;

require_once __DIR__ . '/../../code/external/zend/library/Zend/Loader/ModuleAutoloader.php';
\Zend\Loader\ModuleAutoloader::register();

gets me: 让我:

PHP Fatal error: Uncaught exception 'LogicException' with message 'Passed array does not specify an existing static method (first array member is not a valid class name or object)' in /home/kramer65/myproject/code/external/zend/library/Zend/Loader/ModuleAutoloader.php:312 PHP致命错误:/ home / kramer65 / myproject / code / external / zend / library中出现消息“传递的数组未指定现有静态方法(第一个数组成员不是有效的类名或对象)”的未捕获异常“ LogicException” /Zend/Loader/ModuleAutoloader.php:312

and

require_once __DIR__ . '/../../code/external/zend/library/Zend/Loader/StandardAutoloader.php';
\Zend\Loader\StandardAutoloader::register();

gets me: 让我:

PHP Fatal error: Uncaught exception 'LogicException' with message 'Passed array does not specify an existing static method (first array member is not a valid class name or object)' in /home/kramer65/myproject/code/external/zend/library/Zend/Loader/StandardAutoloader.php:243 PHP致命错误:/ home / kramer65 / myproject / code / external / zend / library中出现消息“传递的数组未指定现有静态方法(第一个数组成员不是有效的类名或对象)”的未捕获异常“ LogicException” /Zend/Loader/StandardAutoloader.php:243

So I checked out line 243 from StandardAutoloader.php, which reads: 因此,我从StandardAutoloader.php签出了第243行,内容为:

spl_autoload_register(array($this, 'autoload'));

I guess I need to provide some array, but I'm unsure which one and how? 我想我需要提供一些数组,但是我不确定哪一个以及如何? Could anybody give me some more appreciated guidance in how to load Zend in my project? 有人可以在我的项目中如何加载Zend方面给我一些更有价值的指导吗? All tips are welcome! 欢迎所有提示!

[EDIT] Let me add that I ask this about Zend 2. [编辑]让我补充一点,我问这个关于Zend 2的问题。

You are calling register() statically, but it is not a static method, which is the cause of the error. 您正在静态地调用register() ,但这不是静态方法,这是导致错误的原因。 I've not done this before, but I think you want something more like this: 我之前没有做过,但是我想您想要更多类似的东西:

require_once __DIR__ . '/../../code/external/zend/library/Zend/Loader/StandardAutoloader.php';
$loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
$loader->register();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM