Home
Quick start
Documentation
Forum
GitHub
Home
Quick start
Documentation
Forum
GitHub
  • Quick Start

    • Introduction
    • Why Phico
    • Installation
  • Example app

    • Scaffolding
    • Routes
    • Requests
    • Responses
    • Events
  • Phico

    • CLI
    • Config
    • Container
    • Filesystem
    • Logger
    • Middleware
    • Request
    • Response
    • Router
    • Support
    • View
  • Libraries

    • Authentication
    • Cache
    • CDN
    • Database
    • Http client
    • Locale
    • Mailer
    • Profiler
    • Query
    • Queue
    • Validation
    • Session
    • View
  • Works

    • Introduction

Queue

Support for pushing and pulling jobs via a Beanstalk queue.

Requirements

You must have access to a Beanstalkd server.

Installation

Using composer

composer require pico-php/queue

Usage

Create a queue watcher

phico queue create watcher [module] [name]
namespace App\{Module}\Watchers;

class {Name}Watcher extends \Phico\Queue\Watcher
{
    public function handle($payload)
    {
        logger()->info('handling queued job', $payload);
    }
}

Submit a job

Use put() to put an item on the queue

// create your payload
$data = [
    'foo' => 'Foo',
    'bar' => 'Bar',
];

// put() the payload on the queue
$job = queue($name)->put($data);
echo $job->id;

Watch for jobs

phico queue watch --handler="\App\Module\Queue\MyHandler" [--watch="comma,separated,list,of,queue,names"]
Last Updated:
Contributors: indgy
Prev
Query
Next
Validation