Google-cloud-php: Class 'Google\Cloud\Vision\VisionClient' not found

Created on 14 Dec 2017  路  9Comments  路  Source: googleapis/google-cloud-php

I am trying to use the google vision api example (the first one) on this page. https://cloud.google.com/vision/docs/detecting-text#vision-text-detection-php
But I keep getting this error: Fatal error: Class 'Google\Cloud\Vision\VisionClient' not found. Has this happened to anyone else and if so how did the fix it?

Most helpful comment

It sounds like you may need to run composer require google/cloud-vision. That should pull down the package and generate the autoload file for you.

All 9 comments

Hey @scottkriesberg ,

Have you included the composer autoload file?

No at the moment the code is exactly like that of the example with my project id and image path filled in. I added this line require __DIR__ . 'vendor/autoload.php'; but it could not find the file. I installed composer, but I think I may be doing this wrong.

It sounds like you may need to run composer require google/cloud-vision. That should pull down the package and generate the autoload file for you.

Should I still include the require __DIR__ . 'vendor/autoload.php'; line before the use Google\Cloud\Vision\VisionClient; line?

Yep! It should look something like this example.

That is what I tried before and downloaded the files using composer. It even said autoload files were generated, but when I run it it cannot find the autoload file and tells me to (include_path='.:'). How do I get it to find the right autoload file?

Take a look at this stackoverflow question and let me know if it helps.

Thank you that seemed to work, but now it is saying "Request had invalid authentication credentials" so I am working on that.

We have a guide that should help with that :).

https://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.46.0/guides/authentication

Was this page helpful?
0 / 5 - 0 ratings