Question
How to enable Queues in the Laravel project for Plesk Laravel Toolkit?
Answer
Before you start, make sure the following is true:
- The latest version of the Laravel Toolkit is installed from the Extensions Catalog. Queues are supported in version 1.4.2-218 or later.
- Laravel version 7.x or later is installed. To check the current Laravel version, run
php artisan -V
to check it.
To enable Queues in the Laravel project, do the following:
- Make sure that scheduled tasks for Laravel project are enabled.
- Integrate the Laravel package into Plesk. In your Git project, in the “composer.json” file, add the following lines:
CONFIG_TEXT: "require": {
. . .
"plesk/ext-laravel-integration": "*"
}Warning: In case a local repository is used, and changes are performed via File Manager, it is required to commit changes by performing step 5 from this article. To avoid overwriting after deploy.
- Re-deploy project at example.com > Manage Laravel application > Deployment, and then click Deploy.
- Select the database you want to process the queues. Depending on the chosen database, follow one of the scenarios below:
For MySQL database:
1. Create the database
2. In the “.env” project file, add the following lines:CONFIG_TEXT: DB_CONNECTION=mysql
DB_HOST=<actual db_host (might be localhost)>
QUEUE_CONNECTION=database
DB_DATABASE=<from step 3.1.1>
DB_USERNAME=<from step 3.1.1>
DB_PASSWORD=<from step 3.1.1>NOTE: Instead of `database_host`, `database_name`, `database_username`, and `database_password`, specify those you have used while creating the database during step 1.
3. Create the necessary tables in the database. Go to example.com > Manage Laravel Application > Artisan, and then run the
migrate
command.For sqlite3 database:
1. Create a .sqlite3 database file, for example, test.sqlite3.
2. In the .env project file, add the following lines:CONFIG_TEXT: DB_CONNECTION=sqlite
QUEUE_CONNECTION=database
DB_DATABASE=<path_to_sqlite3> started website docroot3. Go to example.com > manage laravel application > Artisan execute
php artisan queue:table
4. Go to example.com > manage laravel application > Artisan executemigrate
to create necessary tables in the database
Comments
4 comments
This article gives much information about how to enable it with sql (mysql/sqllite) databases and it works really great.
The only thing mission in the extension and in this article is the behavior of the extension. I encountered a disabled switch button if my application use a cached config file. If I remove the caching for the config the switch button is enabled (clickable again). With the environment variable from the composer package it is possible to activate the queue what isn't mentioned somewhere.
It would be very nice if there is a better overview for the complete behavior of this extension and more information why is the switch disabled for clicks or why it is enabled.
I have both:
Scheduled Tasks on and the Plesk Laravel Toolkit integration package. but the button is still disabled, i can not enable it. why is that?!
manually running php artisan queue:work in plesk
works fine.
I believe this only starts one queue worker.
Many Laravel applications have multiple queues. How do we use this task to start workers for the others?
To enable the "queue" button, you have to un-cache the config:
Then enable the queue, and go in SSH again and cache the config
Please sign in to leave a comment.