Php Symfony\\Component\\Debug\\Exception\\FatalErrorException”,“message:“找不到类'Authy\u Api'
我在laravel/framework:4.2下的composer.json文件中添加了authy php:2.** 在我的控制器中,我将其实例化如下:Php Symfony\\Component\\Debug\\Exception\\FatalErrorException”,“message:“找不到类'Authy\u Api',php,laravel,laravel-4,namespaces,composer-php,Php,Laravel,Laravel 4,Namespaces,Composer Php,我在laravel/framework:4.2下的composer.json文件中添加了authy php:2.** 在我的控制器中,我将其实例化如下: {"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'Authy_Api' not found","file":"\/home\/vagrant\/Code\/curve\/app\/controllers\/
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'Authy_Api' not found","file":"\/home\/vagrant\/Code\/curve\/app\/controllers\/UsersController.php","line":9}}
我运行了composer update和composer dump autoload,这两个都没有解决我的问题
我还尝试了搜索谷歌前10名的搜索结果,但没有一个能解决这个问题
为什么它不能从包中识别类?您应该在控制器中使用:
private $authy;
public function __construct()
{
$this->authy = new Authy_Api(Config::get('authy.authy'));
}
而不是
$this->authy = new \Authy\Authy_Api(Config::get('authy.authy'));
因为Authy_Api是在github自述文件的Authy命名空间中定义的。作曲家要求:
$this->authy = new Authy_Api(Config::get('authy.authy'));
以及使用该类
"authy/php": "2.*"
参考文献
目录authy在供应商中/
$authy_api = new Authy\AuthyApi('#your_api_key');