我正在将我网站的登录系统从 LightOpenID 更新为 Google 的 Oauth 2.0.
I am updating my website's login system from LightOpenID to Google's Oauth 2.0.
当我需要 Client.php 和 Service/Oauth2.php 时出现错误
When I require the Client.php and the Service/Oauth2.php I get an error
致命错误:在第 32 行的/home/myname/repos/website_current/lib/google-api-php-client/src/Google/Service/Oauth2.php 中找不到Google_Service"类
Fatal error: Class 'Google_Service' not found in /home/myname/repos/website_current/lib/google-api-php-client/src/Google/Service/Oauth2.php on line 32
我使用的代码(来自我的 login.php 文件)看起来像这样
The code I am using (from my login.php file) looks like this
require_once(dirname($_SERVER['DOCUMENT_ROOT']).'/lib/autoload.php');
require('Google/Client.php');
require('Google/Service/Oauth2.php');
echo "exit";
exit();
我在 PHP.ini(在/etc/php5/apache2/php.ini 中)添加了包含路径
I have added the include path in the PHP.ini (in /etc/php5/apache2/php.ini) as
include_path = ".:/usr/local/lib/php:/home/myname/repos/website_current/lib/google-api-php-client/src"
所以它似乎我的 Oauth2.php 文件看不到任何其他包含,包括类Google_Service",它是Service.php"中的一个文件夹.
So its seems my Oauth2.php file can't see any of the other includes including the class 'Google_Service' which is one folder up in 'Service.php'.
我的文件夹结构如下:
lib/
... autoload.php
... functions.php
... google-api-php-client/
... src/
... Google/ (etc etc)
public_html/
... login/
...login.php
我不知道为什么会发生这种情况.应该可以看到包含路径,并使用 phpinfo() 显示为包含路径;有人可以给我一些见解吗?
I have no idea why this is occuring. The include path should be seen, and shows up as an included path using phpinfo(); Can someone please give me some insight?
确保您在任何其他 Googlerequire_once"行BEFORE之前添加该行.
Make sure you add the line BEFORE any other Google "require_once" lines.
require_once 'google-api-php-client/autoload.php';
我最后吃了它,它让我挠了 10 分钟.
I had it last and it had me scratching my head for a good 10 minutes.
这篇关于实现 Oauth2 登录,致命错误:找不到“Google_Service"类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!