PHPackages                             udokmeci/yii2-beanstalk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. udokmeci/yii2-beanstalk

ActiveLibrary[Queues &amp; Workers](/categories/queues)

udokmeci/yii2-beanstalk
=======================

Yii2 Beanstalk Client at the top of Paul Annesley's pheanstalk

1.0.4(5y ago)69125.3k—0.6%27[3 issues](https://github.com/udokmeci/yii2-beanstalk/issues)[1 PRs](https://github.com/udokmeci/yii2-beanstalk/pulls)3MITPHPPHP &gt;=5.5CI failing

Since Dec 4Pushed 4y ago7 watchersCompare

[ Source](https://github.com/udokmeci/yii2-beanstalk)[ Packagist](https://packagist.org/packages/udokmeci/yii2-beanstalk)[ Docs](https://github.com/udokmeci/yii2-beanstalk)[ RSS](/packages/udokmeci-yii2-beanstalk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (8)Used By (3)

yii2-beanstalk
==============

[](#yii2-beanstalk)

Yii2 [beanstalkd](http://xph.us/software/beanstalkd/) web and console component which is an interface on the top of [pda/pheanstalk](https://github.com/pda/pheanstalk). Thanks [Paul Annesley](http://paul.annesley.cc/) for such a complete work.

How to use?
===========

[](#how-to-use)

Installation with Composer
--------------------------

[](#installation-with-composer)

Just add the line under `require` object in your `composer.json` file.

```
{
  "require": {
  ...
    "udokmeci/yii2-beanstalk" : "^1.0.0"
  }
}
```

Then run

```
$> composer update
```

Configuration
-------------

[](#configuration)

Now add following lines in to your `main` and `console` configuration file under `components`

```
'beanstalk'=>[
    'class' => 'udokmeci\yii2beanstalk\Beanstalk',
    'host' => '127.0.0.1', // default host
    'port' => 11300, //default port
    'connectTimeout' => 1,
    'sleep' => false, // or int for usleep after every job
],
```

Now add following in to your `console` configuration only.

```
...
'params' => $params,
// add you controller with name and class name next to params.
'controllerMap' => [
    'worker' => [
        'class' => 'app\commands\WorkerController',
    ]
],
```

Producing
---------

[](#producing)

Now if everything is fine, you can run `beandstalkd` and access to controller as

```
\Yii::$app->beanstalk
    ->putInTube('tube', $mixedData, $priority, $delay);
```

`$mixedData` is added on v1.0 for complex usage. Anything else then `string` will be send as `json` format. So you can sent anything within it suppoted by `json`.

Worker
------

[](#worker)

For worker it also has a built in controller which runs an infinite loop and wait for new jobs. Most of the work is done in `BeanstalkController`. All you have to do is to create a controller and action like below.

### Controller

[](#controller)

Create a controller under your `commands` folder. Give the name anything you want to it and `extend` your controller from `udokmeci\yii2beanstalk\BeanstalkController`

##### Example Controller

[](#example-controller)

```
