Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nidhiwebsolutions's avatar

Class "SpotifyWebAPI\Session" not found {"exception":"[object] (Error(code: 0): Class \"SpotifyWebAPI\\Session\" not found

I am trying to use https://github.com/jwilsson/spotify-web-api-php. It is working properly in the Jobs if I use ::dispatchSync, but giving error if I use ::dispatch

0 likes
4 replies
vincent15000's avatar

Can you show your code please ?

The whole code with dispatch and the code with dispatchSync and with all the use declarations.

nidhiwebsolutions's avatar

@vincent15000

UpdateAccountFollowers::dispatchSync($account);

UpdateAccountFollowersJob::dispatch($account);

Job use declarations

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

use App\Dsps\Spotify;

Spotify.php use declarations

use SpotifyWebAPI\Session;
use SpotifyWebAPI\SpotifyWebAPI;
use SpotifyWebAPI\SpotifyWebAPIException;

and this is the code block which is giving error

$session = new Session(
            settings('spotify.client_id'),
            settings('spotify.client_secret'),
            settings('spotify.redirect_uri')
        );
1 like
vincent15000's avatar

@nidhiwebsolutions What I see is that you have two different classes.

UpdateAccountFollowers::dispatchSync($account);

UpdateAccountFollowersJob::dispatch($account);

Perhaps you have something wrong in the UpdateAccountFollowersJob class ?

But impossible to help you if you don't show the whole code.

nidhiwebsolutions's avatar

@vincent15000 Thanks for your support, but I found the error. I had to restart the queue, I was checking the docs and found this

Since queue workers are long-lived processes, they will not notice changes to your code without being restarted. So, the simplest way to deploy an application using queue workers is to restart the workers during your deployment process. You may gracefully restart all of the workers by issuing the queue:restart command:

php artisan queue:restart

1 like

Please or to participate in this conversation.