安装完成后,可以正常访问,但是访问 http://www.lulumall.cn/customer/account/login 时就报错了。错误如下:
Class :ame must be a valid object or a string
打印$apiConfig发现$apiConfig是空值,好奇怪。请问有没有哪里漏配置了? 用的laraDock(http://laradock.io/)的docker环境,php7.1。
$apiConfig
您好,我看了一下这个问题
您的报错位置为:/vendor/fancyecommerce/fecshop/lib/google/lib/Google_Client.php
public function __construct($config = array()) { global $apiConfig; $apiConfig = array_merge($apiConfig, $config); self::$cache = new $apiConfig['cacheClass'](); self::$auth = new $apiConfig['authClass'](); self::$io = new $apiConfig['ioClass'](); }
你的报错为:Class name must be a valid object or a string
Class name must be a valid object or a string
$apiConfig的部分赋值为: /vendor/fancyecommerce/fecshop/lib/google/lib/Google_Client.php
代码:require_once "config.php";
require_once "config.php";
也就是打开文件:
在这里对$apiConfig进行了赋值,在require_once "config.php";这个代码后面打印输出
// hack around with the include paths a bit so the library 'just works' set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path()); require_once "config.php"; var_dump($apiConfig);
结果如下:
array(13) { ["use_objects"]=> bool(false) ["application_name"]=> string(0) "" ["oauth2_client_id"]=> string(0) "" ["oauth2_client_secret"]=> string(0) "" ["oauth2_redirect_uri"]=> string(0) "" ["developer_key"]=> string(0) "" ["site_name"]=> string(15) "www.example.org" ["authClass"]=> string(13) "Google_OAuth2" ["ioClass"]=> string(13) "Google_CurlIO" ["cacheClass"]=> string(16) "Google_FileCache" ["basePath"]=> string(26) "https://www.googleapis.com" ["ioFileCache_directory"]=> string(18) "/tmp/Google_Client" ["services"]=> array(1) { ["oauth2"]=> array(1) { ["scope"]=> array(2) { [0]=> string(48) "https://www.googleapis.com/auth/userinfo.profile" [1]=> string(46) "https://www.googleapis.com/auth/userinfo.email" } } } }
你在你的环境里面看看,到底存在什么问题,我的环境是centos 6
在你的环境里面顺藤摸瓜,看看到底是什么原因导致的 $apiConfig 为空值,然后把原因在这里贴一下.
谢谢terry的热心帮助,我换了一个php版本就好了,可能是php7.1的一个bug。现在php5.6。明显include的时候,var_dump($apiConfig);没有发现$apiConfig有值,很奇怪。具体原因我要再找找,找到了我在这里再回复一下。
var_dump($apiConfig);
很奇怪,第二次打开,$apiConfig又没有值了。 这是一个很诡异的事情。请terry帮忙。谢谢!
把require_once 改成require或者include就可以了,include_once也不行,为什么我的环境会这样? 是php的哪个配置不对?
高版本都是向下兼容的,php5.6可以用,php7一般也可以用的
你按照上面的逻辑看看是什么问题
/vendor/fancyecommerce/fecshop/lib/google 这个是一个官方的库包,一般不会存在问题,
要么你把第三方google 和fb登录的部分先注释掉,有空再回来看这个问题
好的,谢谢!我先这样子用着。我也去看下,为什么require_once就不行。只能require。
其实现在5.6也得require,不能用require_once。
@monlone #8楼 你的意思是,如果改成require 就没有报错了吗?
我查了下,是支持的 http://php.net/manual/zh/function.require-once.php
是的,换成require就可以了。我也很纳闷,一直在找机会解决。有什么进展,我在这里说吧。