我正在将我的网站登录系统从LightOpenID更新为Google的Oauth 2.0.
当我需要Client.php和Service/Oauth2.php时,我收到错误
致命错误:第32行/home/myname/repos/website_current/lib/google-api-php-client/src/Google/Service/Oauth2.php中未找到"Google_Service"类
我正在使用的代码(来自我的login.php文件)看起来像这样
require_once(dirname($_SERVER['DOCUMENT_ROOT']).'/lib/autoload.php');
require('Google/Client.php');
require('Google/Service/Oauth2.php');
echo "exit";
exit();
Run Code Online (Sandbox Code Playgroud)
我在PHP.ini中添加了include路径(在/etc/php5/apache2/php.ini中)
include_path = ".:/usr/local/lib/php:/home/myname/repos/website_current/lib/google-api-php-client/src"
Run Code Online (Sandbox Code Playgroud)
所以它似乎我的Oauth2.php文件看不到任何其他包括类'Google_Service',这是'Service.php'中的一个文件夹.
我的文件夹结构如下所示:
lib/
... autoload.php
... functions.php
... google-api-php-client/
... src/
... Google/ (etc etc)
public_html/
... login/
...login.php
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会这样.应该看到包含路径,并使用phpinfo()显示为包含的路径; 有人可以给我一些见解吗?
对我来说这似乎是一个简单的问题,但搜索没有产生任何用处.
我有如下代码:
for key, v in enumerate(ranges):
### Used to switch between voltage steps
second_iter = 0
for step in v:
### Set voltage sources to differential voltages
if second_iter == 0:
self.tf.institf.dcm.vsource1(step)
second_iter = 1
elif second_iter == 1:
self.tf.institf.dcm.vsource2(step)
self.measure_something()
Run Code Online (Sandbox Code Playgroud)
v是2元素列表.范围是v的列表.我想遍历每个v,但每次使用不同函数中的第二个元素.
是否有一种pythonic方式来编写上面的代码?
编辑:为了澄清,我想在之后做一些单独的代码测量某些东西.所以我不能同时设置这两个功能.