找到你要的答案

Q:How to load PHP library with no Namespaces in PHP ZF2?

Q:如何加载PHP库与PHP ZF2没有命名空间?

Similar to the poster on ZF2: autoloading libraries without namespaces, I need to load a non-namespaced library without composer.

Specifically, I need to load HybridAuth into Zend Framework 2. I intend to use the submodule: https://github.com/heiglandreas/HybridAuth to interface with my application.

Do I need to create a classmap file?

类似于ZF2海报:自动加载库没有命名空间,我需要不作曲家负荷非命名空间库。

Specifically, I need to load HybridAuth into Zend Framework 2. I intend to use the submodule: https://github.com/heiglandreas/HybridAuth to interface with my application.

我需要创建一个ClassMap文件吗?

answer1: 回答1:

Load the library with require/require_once and use \ sign. This is the default namespace for PHP.

加载库要求/ require_once和使用标志。这是PHP的默认命名空间。

answer2: 回答2:

As it turns out, the classmap strategy was the correct approach. Essentially, I needed to create the files that composer would have created on my own.

So, I register the namespaces to the directories and included the classmap.php file...

Using: http://framework.zend.com/manual/current/en/modules/zend.loader.class-map-autoloader.html

Zend\Loader\ClassMapAutoloader()

Taking advantage of the fact ZF2 looks for an autoload.php file in the vendor directory, I just placed all my code there...

事实证明,这是正确的做法,ClassMap策略。从本质上讲,我需要创建的文件,作曲家将创建我自己。

所以,我登记的目录包括classmap.php命名空间和文件…

使用:http://framework.zend.com/manual/current/en/modules/zend.loader.class-map-autoloader.html

Zend\Loader\ClassMapAutoloader()

利用事实ZF2寻找供应商目录autoload.php文件,我只是把我所有的代码都有…

php  zend-framework2  composer-php  hybridauth