Dees Oomens
Dees Oomens

Reputation: 5082

Fatal Error: Class 'Pheanstalk\Pheanstalk' not found

On my API I wanted to change queue drivers. I wanted to switch from Beanstalkd to Redis.

So in my composer.json I changed my dependencies "pda/pheanstalk": "^3.0" to "predis/predis": "~1.0". Then I went to Laravel Forge, added a new Queue Worker which looks like this:

Queue workers

I updated my .env file: QUEUE_DRIVER=redis and ran composer update. After that I tried to fire a notification (with email), the notification implements the ShouldQueue interface and uses the Queueable trait. The notification was send with success (over the queue as well).

At that moment I was happy, but wait... I check my Sentry issues and saw the following error:

Fatal Error: Class 'Pheanstalk\Pheanstalk' not found in vendor/laravel/framework/src/Illuminate/Queue/Connectors/BeanstalkdConnector.php in connect at line 21.

At this moment the bug/issues occurs around 200 times a minute.

What I tried:

  1. Remove all failed jobs from queue
  2. Restart the server
  3. Even installing the pda/pheanstalk package over composer again.

So at the moment I've the pda/pheanstalk installed but don't have the beanstalkd queue worker running and I'm still getting the Class 'Pheanstalk\Pheanstalk' not found error.

My best guess is that when I removed the beanstalkd queue worker and removed the package with composer, their was a job running in the queue worker and now it's retrying that job over and over. But of course I could be totally wrong.

Any ideas on what is going wrong here?

EDIT

I've now deleted my site from Forge, checked if the code was deleted. In Sentry the error is still being logged.. The project doesn't even exists on the server anymore.

Upvotes: 1

Views: 3810

Answers (5)

Raju Singh
Raju Singh

Reputation: 780

As official laravel documentation, Please install the latest version of Beanstalkd

Beanstalkd: pda/pheanstalk ~4.0

For more info, Please check this https://laravel.com/docs/9.x/queues#other-driver-prerequisites

Upvotes: 1

Thoan Trịnh
Thoan Trịnh

Reputation: 1

Install pheanstalk as a dependency with composer:

composer require pda/pheanstalk

In PHP file

use Pheanstalk\Pheanstalk;

Upvotes: 0

vladko
vladko

Reputation: 1033

Make sure you that you remove any references to this class in conig/app.php as well as run composer dump-autoload.

You may want to do a global search for this class in your app to make sure it's gone. Lastly, delete the vendor folder, if it's still there.

Upvotes: 0

Laurence
Laurence

Reputation: 60068

Sounds like you havent restarted the queue to use the new settings?

Log into the server and run php artisan queue:restart

The other thing - did you have Supervisor or something already running the older queue config? If so - that could be restarting the older queue.

Upvotes: 1

Kuba Biały
Kuba Biały

Reputation: 19

Did you register Pheanstalk\Pheanstalk within your config/app.php file?

Usually that's the case, Laravel won't see any dependencies that were not registered.

Inside of array containing configuration for your app, find `providers', and put namespace of given class inside that array.

Upvotes: 0

Related Questions