[SOLVED] Google_Service_Youtube class not found (only on a Debian Server)
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 :
- I installed Apache2 and configured it on my Debian server
- I installed the PHP7 version
- I uploaded my website on my Debian website folder
- I installed composer in this directory
- I initialized my project with composer, adding the google/apiclient in the same time
- I get the error.
Does anyone have an idea about where this error can come from?
Thanks a lot for your attention.
Windows is not case sensitive and Linux is. So try changing the reference to the class Google_Service_Youtube to Google_Service_YouTube.
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 !!!
Thanks, @lasselehtinen 🥇 . Couldn't for the life of me work out what I had done wrong.
It will require Google_Service_YouTube library to make it workout. Try installing the library and this error is particular for libraries.
@avinash-thombre The library was already installed. It was just a case sensitive issue.
Why have I been assigned? :smile: I don't always get what happens but this seems to be closed since 2018
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 Yup, it also fixes Undefined type 'Google_Service_YouTube' warning I was getting from intellisense.