- add keys in .env file :
X_RapidAPI_Key=xxxxxxxx
X_RapidAPI_Host=xxxxxxx
To avoid response delay SendEmail class implement "ShouldQueue", so it can be processed in the background when the form is submitted.
NOTE : using Queue was not asked in the exercise, to test the applciation without queues configuration, please remove " implements ShouldQueue" from SendEmail class and sending emails will be processed synchronously
Configurations steps :
- Set up database queue driver : to use the database queue driver, you will need a database table to hold the jobs. To generate a migration that creates this table, run the queue:table Artisan command. Once the migration has been created, you may migrate your database using the migrate command:
- php artisan queue:table
- php artisan migrate
- Instruct application to use database driver by updating queue_connection variable at .env file
QUEUE_CONNECTION=database
- Add mailtrap credentials to catch emails
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=xxxxxxxxx
MAIL_PASSWORD=xxxxxxxxx
- Running the queue worker You may run the worker using the queue:work Artisan command.
- php artisan queue:work