I have a project build by Phalcon.
Everything is ok. Now I want to use Gearman in my project to do some tasks in background (sending email, process image, convert video,...)
I have a file worker.php like this:
<?php
$worker = new GearmanWorker();
$worker->addServer();
$worker->addFunction("send_email", function(GearmanJob $job) {
    $email = $job->workload();
    echo "Sending email: $email \n";
    mail($email, "test gearman", "this is a test from gearman");
    $job->sendStatus(1, 1);
});
while ($worker->work());In function send_email, how to access Phalcon like this (while worker.php is a single file, outside from the project)
<?php
$worker = new GearmanWorker();
$worker->addServer();
$worker->addFunction("send_email", function(GearmanJob $job) {
    //accss Phalcon model
    $user = User::findFirstById();
    $email = $user->email;
    echo "Sending email: $email \n";
    mail($email, "test gearman", "this is a test from gearman");
    $job->sendStatus(1, 1);
});
while ($worker->work());