I am trying to use Laravel background jobs. I have a library, which imports lots of images.
For queued jobs, I am following Laravel documentation:
First (create table):
php artisan queue:table
php artisan migrate
Then configuration in .env file for Redis:
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=43216
Create a job:
php artisan make:job CarsJob
CarsJob:
public function handle(){
$cars = new CarsLibrary();
$CarsLibrary->importAll();
}
Dispatching a job in a some action in the controller:
First what I have tried:
$importCarsJob = (new ImportCarsJob())->onQueue('import_cars');
$this->dispatch($importCarsJob );
Second what I have tried:
$importCarsJob = new importCarsJob ();
$this->dispatch($importCarsJob );
I have enabled Redis in my hosting. It is shared hosting.
If I access the URL, I see that this job is not in the background, because it needs more than a minute to finish the request.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2XisWtC
via IFTTT
Aucun commentaire:
Enregistrer un commentaire