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:
"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: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: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