2015-11-05 77 views
0

我想加载一个在ZF2中有一个下划线的类。Zend Framework 2加载类PHPGangsta_GoogleAuthenticator

这是项目,我想使用:https://github.com/PHPGangsta/GoogleAuthenticator

的文件夹路径是这样的:

/module 
    /Application 
     /Service 
      /MyService.php 
/vendor/ 
    /PHPGangsta 
     /GoogleAuthenticator.php 

GoogleAuthenticator.php有一个名为PHPGangsta_GoogleAuthenticator,我想在MyService.php使用类,而不必require任何文件。

此外,我无法更改PHPGangsta中的文件,因为该项目是在git下进行子模块化。

你能帮忙配置zf2类自动加载吗?

回答

0

假设您使用Composer(这是推荐的方法)安装ZF2,编辑您的composer.json以将phpgangsta/googleauthenticator添加到require部分。然后运行composer install。而已。然后,您应该可以在应用程序中使用该库 - 不需要执行任何其他自动加载配置。

+0

我无权访问作曲家。整个应用程序在git下。所以子模块是我添加新组件的唯一方式。 – ep0

+0

“你没有访问权限”是什么意思?你仍然可以安装它,不是吗? –

+0

我的意思是我可以在本地执行此操作,但不能在部署机器上执行。而在这些上,作曲家将不会被安装。 – ep0