zend-framework - Zend框架1.11 : how to autoload a class that uses namespaces

标签 zend-framework namespaces autoload

我有一个 Zend Framework 1.11 应用程序,我想使用一个名为 RandomLib 的包。问题是,它没有自动加载器,我尝试阅读有关使用自动加载器的 Zend 文档,但我无法理解它。

我已将 RandomLib 文件夹放入我的库目录中。我的 Bootstrap.php 文件中需要什么样的代码来自动加载该类?

最佳答案

从版本 1.10.0 开始,Zend Framework 现在允许从 PHP 命名空间加载类。此支持遵循与 » PHP Framework Interop Group PSR-0 引用实现中相同的准则和实现。 Source

  1. RandomLib/lib的内容放在library/RandomLib
  2. application.ini 中添加 autoloaderNamespaces[] = "RandomLib"

关于zend-framework - Zend框架1.11 : how to autoload a class that uses namespaces,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17121268/

相关文章:

zend-framework - 如何清除zend中两个表单页面上的一组错误

c++ - 更简洁代码的嵌套命名空间

php - 为什么在通过 PhpUnit 运行测试时找不到我的自定义 TestCase 类?

PHP 自动加载 : Preventing 'cannot redeclare <class>' in all constellations?

php - Zend_Gdata 和 OAuth

zend-framework - 如何在zend框架中使用phpexcel

php - Zend 框架中的 URL 验证 1

.net - 不改变 "http://tempuri.org/"引用是否只是缺乏专业精神或更多?

xml - XSLT for-each 迭代(祖先属性的问题)

PHP fatal error :Uncaught Error: Failed opening required 'new-project/vendor/autoload.php' (include_path ='.;C:\php\pear' ) in E:\new-project\artisan:18