We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to use Phalcon\Queue\Beanstalk?

https://docs.phalcon.io/en/latest/reference/queue.html

<?php

//Connect to the queue
$queue = new Phalcon\Queue\Beanstalk(array(
    'host' => '192.168.0.21'
));

//Insert the job in the queue
$queue->put(array('processVideo' => 4871));

processVideo is name of job? What mean 4871? Where processVideo should be defined?



51.2k

processVideo is just a key to store it in your queue. You can name it whatever you want. 4871 is the id of the video. A simple example would be if you have a table in database that holds information about video files that needs to be processed:

Table columns id, file_path, is_processed

When you upload a video file, you store the information in your video table, with flag is_processed = 0 , then you add the file to the queue

$video = new VideoModel();
$video->setFilePath('PATH_TO_VIDEO_FILE');
$video->setIsProcessed(0);
$video->save();

// $video->getId() will give you the id (in the above example 4871)
$queue->put(array('processVideo' => $video->getId()));