[英]Symfony\\Component\\Debug\\Exception\\FatalErrorException“,”message“:”Class 'Authy_Api' not found
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'Authy_Api' not found","file":"\/home\/vagrant\/Code\/curve\/app\/controllers\/UsersController.php","line":9}}
I added "authy-php": "2.*"
to my composer.json file under "laravel/framework": "4.2.*"
我在"laravel/framework": "4.2.*"
下的composer.json文件中添加了"authy-php": "2.*"
"laravel/framework": "4.2.*"
In my controller I instantiate it like so: 在我的控制器中,我将其实例化为:
private $authy;
public function __construct()
{
$this->authy = new Authy_Api(Config::get('authy.authy'));
}
I ran composer update
and composer dump-autoload
and neither of the two solved my problem. 我运行了composer update
和composer dump-autoload
,两者都没有解决我的问题。
I also tried to do the top 10 google search results none of which fixed the problem. 我也尝试做十大谷歌搜索结果,没有一个解决了这个问题。
Why is it not recognizing the class from the package? 为什么无法从包装中识别出班级?
You should use in your controller: 您应该在控制器中使用:
$this->authy = new \Authy\Authy_Api(Config::get('authy.authy'));
and not 并不是
$this->authy = new Authy_Api(Config::get('authy.authy'));
because Authy_Api
is defined in Authy
namespace 因为Authy_Api
是在Authy
名称空间中定义的
From the github readme. 来自github自述文件。 For composer require: 对于作曲家,要求:
"authy/php": "2.*"
and for using the class 和使用班级
$authy_api = new Authy\AuthyApi('#your_api_key');
Reference 参考
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.