google-api-php-client icon indicating copy to clipboard operation
google-api-php-client copied to clipboard

[SOLVED] Google_Service_Youtube class not found (only on a Debian Server)

Open AlexandreGerault opened this issue 10 years ago • 8 comments

Hi!

I developed a very little website which just shows the three last videos from a Youtube channel and other some text. The only php code is to get these videos.

To get this videos, I just use the Google Api client (Youtube Data v3) that I installed with composer. It works fine on my Wamp (local, Windows) but on the production server, I don't understand why I get Fatal error: Uncaught Error: Class 'Google_Service_Youtube' not found in /path/to/www/index.php:12 Stack trace: #0 {main} thrown in /path/to/www/index.php on line 12

So here are the steps I followed :

  1. I installed Apache2 and configured it on my Debian server
  2. I installed the PHP7 version
  3. I uploaded my website on my Debian website folder
  4. I installed composer in this directory
  5. I initialized my project with composer, adding the google/apiclient in the same time
  6. I get the error.

Does anyone have an idea about where this error can come from?

Thanks a lot for your attention.

AlexandreGerault avatar Nov 11 '16 22:11 AlexandreGerault

Windows is not case sensitive and Linux is. So try changing the reference to the class Google_Service_Youtube to Google_Service_YouTube.

lasselehtinen avatar Nov 12 '16 16:11 lasselehtinen

I'm sorry but I don't see any difference... Maybe I didn't understand your answer (I understood for case sensitive). EDIT : OHHHHHH ! Thanks ! This is T and not t !!! Thanks !!!

AlexandreGerault avatar Nov 12 '16 17:11 AlexandreGerault

Thanks, @lasselehtinen 🥇 . Couldn't for the life of me work out what I had done wrong.

schm-dt avatar Sep 09 '17 09:09 schm-dt

It will require Google_Service_YouTube library to make it workout. Try installing the library and this error is particular for libraries.

avinash-thombre avatar May 25 '18 09:05 avinash-thombre

@avinash-thombre The library was already installed. It was just a case sensitive issue.

AlexandreGerault avatar May 26 '18 19:05 AlexandreGerault

Why have I been assigned? :smile: I don't always get what happens but this seems to be closed since 2018

AlexandreGerault avatar Feb 02 '21 13:02 AlexandreGerault

Google_Service_YouTube is a class alias for Google\Service\YouTube, so instead of doing this:

// Define service object for making API requests. $service = new Google_Service_YouTube($client);

as stated in the documentation,you can do:

// Define service object for making API requests. $service = new YouTube($client);

nizigama avatar May 30 '22 18:05 nizigama

@nizigama Yup, it also fixes Undefined type 'Google_Service_YouTube' warning I was getting from intellisense.

harryqt avatar Oct 14 '22 14:10 harryqt