require_once(Google/Auth/AssertionCredentials.php): failed to open stream: No such file or directory

纵饮孤独 提交于 2019-12-02 01:36:24

问题


I'm trying to do a very simple:

require_once 'vendor/google/src/Google/Client.php';
require_once 'vendor/google/src/Google/Service/Plus.php';

...and I get this error:

require_once(Google/Auth/AssertionCredentials.php): failed to open stream: No such file or directory

Why?

I'm using the latest version available on https://github.com/google/google-api-php-client and seems that in Client.php each require_once uses a wrong path... or not?

Any help will be greatly appreciated!

Thanks a lot,
Niccolò


回答1:


For your problem you need to add the base directory of the library in the php 'include_path'.

Try putting this line of code before the require_once

set_include_path( get_include_path() . PATH_SEPARATOR . 'vendor/google/src' );



回答2:


Above didn't work for my WordPress plugin, but I managed to solve it like this:

In Client.php before require_once block add:

set_include_path( plugin_dir_path( __FILE__ ) . '../' );

Hope it helps.



来源:https://stackoverflow.com/questions/20994928/require-oncegoogle-auth-assertioncredentials-php-failed-to-open-stream-no-su

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!