PHP code example of pyrowman / pheanstalk

1. Go to this page and download the library: Download pyrowman/pheanstalk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pyrowman / pheanstalk example snippets




// Hopefully you're using Composer autoloading.

use Pheanstalk\Pheanstalk;

$pheanstalk = new Pheanstalk('127.0.0.1', 'admin', 'admin');


// Create a simple Worflow with one job inside

$workflow = $pheanstalk->createTask('Sleep', 'Test', '/bin/sleep 80');

// Put the job into instance execution

$pheanstalk->put($workflow);

// ----------------------------------------
// check server availability

$pheanstalk->getConnection()->isServiceListening(); // true or false

//-----------------------------------------
// Add a scheduler for the job (by default in continous)

$workflowSchedule = $pheanstalk->createSchedule($workflow, new TimeSchedule());

//-----------------------------------------
// Edit a workflow

$workflow->setGroup('2nd test group');
$pheanstalk->update($workflow);

//-----------------------------------------
// Getting infos on the execution of a workflow
$workflowInstancesExecuting = $pheanstalk->getWorkflowInstances($workflow, GetWorkflowInstancesCommand::FILTER_EXECUTING);
$workflowInstancesTerminated = $pheanstalk->getWorkflowInstances($workflow, GetWorkflowInstancesCommand::FILTER_TERMINATED);

//-----------------------------------------
// Delete a job 

if ($workflow = $pheanstalk->workflowExists('Sleep'))
    $pheanstalk->delete($workflow);