Hi,
Based on the instructions below, I am trying to add login to my PHP application using the Auth0 PHP-SDK:
Despite trying endless methods and different examples found on web, I’m still getting the error -
“Fatal error: Uncaught Error: Class Auth0\SDK\Configuration\SdkConfiguration not found”
I am wondering if it is related to some Apache or PHP settings of my Plesk installation, since it happens with any class, not just auth0. I’m using DigitalOcean VM, with Plesk installed.
It would be greatly appreciated if you could help me. Unfortunately, I was not able to find a solution in the documentation.
Thank you,
Mati
It sounds like your PHP installation is failing the load the SDK files.
Can you confirm you have Composer accessible and installed the SDK using Composer?
Can you confirm your app is loading the Composer autoload.php file, from within the vendor subdirectory?
From a shell, can you run ‘composer show -I’ from your project directory root (where your composer.json and lock file are) and share the output here to help diagnose.
The current response to composer require auth0/auth0-php is attached -
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^7.9 for auth0/auth0-php
./composer.json has been updated
Running composer update auth0/auth0-php
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files10 packages you are using are looking for funding.
The current response to cat vendor/autoload.php -
<?php
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
exit(1);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit8edebcea30a518a9b07a52ecac828c00::getLoader();
The current response to composer show -l
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Color legend:
- patch or minor release available - update recommended
- major release available - update possible
- up to date version
auth0/auth0-php 7.9.2 7.9.2 Auth0 PHP SDK.
auth0/php-jwt 3.3.4 3.2.5 A simple library to work with JSON Web Token and JSON Web Signature
guzzlehttp/guzzle 7.4.5 7.4.5 Guzzle is a PHP HTTP client library
guzzlehttp/promises 1.5.1 1.5.1 Guzzle promises library
guzzlehttp/psr7 1.9.0 2.4.0 PSR-7 message implementation that also provides common utility methods
nyholm/psr7 1.5.1 1.5.1 A fast PHP7 implementation of PSR-7
php-http/message-factory v1.0.2 v1.0.2 Factory interfaces for PSR-7 HTTP Message
psr/container 2.0.2 2.0.2 Common Container Interface (PHP FIG PSR-11)
psr/http-client 1.0.1 1.0.1 Common interface for HTTP clients
psr/http-factory 1.0.1 1.0.1 Common interfaces for PSR-7 HTTP message factories
psr/http-message 1.0.1 1.0.1 Common interface for HTTP messages
psr/log 3.0.0 3.0.0 Common interface for logging libraries
psr/simple-cache 1.0.1 3.0.0 Common interfaces for simple caching
ralouphie/getallheaders 3.0.3 3.0.3 A polyfill for getallheaders.
symfony/deprecation-contracts v3.1.0 v3.1.0 A generic function and convention to trigger deprecation notices
symfony/http-client v6.1.1 v6.1.2 Provides powerful methods to fetch HTTP resources synchronously or asynchronously
symfony/http-client-contracts v3.1.0 v3.1.0 Generic abstractions related to HTTP clients
symfony/polyfill-mbstring v1.26.0 v1.26.0 Symfony polyfill for the Mbstring extension
symfony/service-contracts v3.1.0 v3.1.0 Generic abstractions related to writing services
I appreciate your help once again, thank you,
Mati
Hey @matigo Thanks for the extra info. So, that explains the situation: you’re using the previous version of the PHP SDK, which our documentation doesn’t reference anymore. The class in question is new to V8 of the PHP SDK.
The fact that Composer installed this version of the SDK for you instead of the latest tells me your environment is running an older and unsupported version of PHP. Can you check what version of PHP is installed? Our supported PHP versions follow the official support lifecycle, which can be found here: PHP: Supported Versions
Unusual! Was this a fresh installation of the SDK, or are you migrating a project of some kind? I’m not certain why Composer would have delivered SDK V7 on a new project with PHP 8.1, that doesn’t make sense. You might run php -v from your shell just in case, perhaps, your environment is mistakenly invoking an outdated version of the PHP somewhere on the host. (Most likely Pesk upgraded your PHP runtime after the Composer install occurred, but it’s impossible to say.)
In any case, try running composer require auth0/auth0-php "^8.0". As a last resort, you can try manually setting the version in your composer.json file to ^8.0 and running composer install again.
Thanks a lot. It finally worked when I required the 8.0 version.
I’ll use this thread for another question:
I have integrated Auth0 login into my MediaWiki at https://wiki.[mydomain]/. It works perfectly.
I have another subdomain (let’s call it https://site.[mydomain]/) that contains a simple php website. My application used in wiki’s subdomain has that subdomain added to its cross origin settings.
Now I just want to add simple session check to the other sub-domain - if the user is already logged in, he can continue to site.mydomain - otherwise he will be redirected to authentication login (I’m using Auth0’s login form, not mine)
I have tried many code examples, but I am unable to make it work. Can you give me an example of code for this scenario in a production environment (not a local environment)?
As to your other question: Assuming both apps are using the same configuration, and you have configured the ‘cookieDomain’ to “.mydomain.whatever” (so the session cookie is accessible to all subdomains) you shouldn’t need to do any particularly special coding; it should just work.
The only practical issue I foresee there is both apps need to use the same Auth0 Application details, which means the redirect url will need to point to a specific url on one of those apps to handle the call back.
To check if a session is available you can just use the ‘getCredentials()’ method from the SDK.