Plesk

How to enable Queues in the Laravel project for Plesk Laravel Toolkit

Question

How to enable Queues in the Laravel project for Plesk Laravel Toolkit?

Answer

Before you start, make sure the following is true:

To enable Queues in the Laravel project, do the following:

  1. Make sure that scheduled tasks for Laravel project are enabled.
  2. 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.

  3. Re-deploy project at example.com > Manage Laravel application > Deployment, and then click Deploy.
  4. 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 docroot

      3. Go to example.com > manage laravel application > Artisan execute php artisan queue:table
      4. Go to example.com > manage laravel application > Artisan execute migrate to create necessary tables in the database