Skip to content
Advertisement

How to call a class from vendor folder when using a composer?

I am investigating jwt token examples from this link – https://github.com/firebase/php-jwt

So i run:

JavaScript

And now i have new files and folders in my root directory of my site: vendor, composer.json and composer.lock. Folder “vendor” contents “firebase/php-jwt” folder.

So i tried to run an example script inside my root site’s folder (test.php, for example) with this content:

JavaScript

And when i run it, i see:

Fatal error: Uncaught Error: Class ‘FirebaseJWTJWT’ not found in /var/www/html/jwt/test.php:20 Stack trace: #0 {main} thrown in /var/www/html/jwt/test.php on line 20

So how can i use a class FirebaseJWTJWT right?

Advertisement

Answer

From composer’s Autoloading page:

For libraries that specify autoload information, Composer generates a vendor/autoload.php file. You can include this file and start using the classes that those libraries provide without any extra work:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement