Unable to include Cloud Storage Tools library in A

2019-08-06 12:16发布

问题:

In my CodeIgniter project, I am unable to include the Cloud Storage Tools PHP library, as used in lots of example PHP code.

I have put the following at the top of an Controller extension, but I get an error when trying to use "CloudStorageTools::createUploadUrl()"

require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;

This is the error:

PHP Fatal error: Class 'CloudStorageTools' not found

Is this library automatically in the App Engine?

I thought this library was automatically there (seeing as there is an automatic Google Cloud Storage wrapper so you can use gs:// for uploading) but it seems like this isn't the case.

回答1:

You don't need the "require_once" statement as all SDK classes are auto-loaded: https://cloud.google.com/appengine/docs/php/#PHP_Automatic_class_loading