PHPackages                             tebazil/yii2-vodka-behavior - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tebazil/yii2-vodka-behavior

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

tebazil/yii2-vodka-behavior
===========================

Yii2 joke extension that intercepts the application response and replaces it with joke messages

0.0.0(10y ago)59BSD-3-ClausePHP

Since Sep 5Pushed 10y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (0)

Vodka. Your application talks to you (tm)
=========================================

[](#vodka-your-application-talks-to-you-tm)

Vodka is a joke "drunk" application behavior that intercepts the response at a given probability (default is 0.75) and replaces it with some "quote" from the default or custom generators. Works for both web and console application.
Here is the output example:

```
VODKA BEHAVIOR says:
Obna obbbaaoo n  bnbnb oabb bnn
a bn  a anba baaooaobboboaabna n  nboo oan b a   oa nbonbao ona b
  obnob b nob bb  nnnb  boaban b n o anon oaoannan oaaooaaababobo
anonob a anooaao nb aa ooo bb  n bnnabab abbbbno bnb nnoboo noano
ooanabaaoonn anaao ab n an  ona  n o  anaaa nbobbann  anoo boa ob
banaooa    noanaonbbno o oono  a .

```

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ composer require tebazil/yii2-vodka-behavior
```

or add

```
"tebazil/yii2-vodka-behavior": "*"

```

to the `require` section of your `composer.json` file.

Basic usage
-----------

[](#basic-usage)

VodkaBehavior is a typical yii2 behavior, that can be attached to the application. The most simple way is to attach the behavior in application's config section:

```
return [
    'id' => 'basic-console',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log', 'gii'],
    ...
	'as vodka'=> [
		'class'=>'tebazil\yii2\behaviors\vodka\VodkaBehavior',
	],
	...
	'components'=>[
	...
	],
	...
```

There. Now when you call your application (even with non existent routes), "quotes" will appear in browser/console at a given probability.

Advanced usage
--------------

[](#advanced-usage)

You may also benefit from some additional configuration. You can configure `generators`, `probability`, and `phrase` to further customize a drunk behavior.
`phrase` (string) - is a prefix phrase to generator's output. The default value is `VODKA BEHAVIOR says:`
`probability` (float) - is a probability from 0 to 1 at which the output will be intercepted. 0 means behavior never fires. 1 means it fires all the time. The default value is `0.75`. `generators` is the array of anonymous functions that generate the output. When you define this parameter, the default generators are replaced with the ones you specified. The anonymous function takes no parameters and returns output. For universal usage, make sure you return string from a generator. The default value of `generators` is array of two bundled generators.

Here is the example of full configuration:

```
return [
    'id' => 'basic-console',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log', 'gii'],
    ...
	'as vodka'=> [
		'class'=>'tebazil\yii2\behaviors\vodka\VodkaBehavior',
		'probability'=>0.95,
		'phrase'=>
		    'Hi, I am your application ... Intrigued, huh? Here is what I have to say:',
		'generators'=>[
		function() {
		  return 'I think everything is possible.
		  You just have to listen to your heart and work hard.';
		},
		function() {
		    $coreDevs = ['Qiang','Cebe','Samdark','Will Smith'];
		    $endingPhrases = [
		        'The resemblance is unique.',
		        'Sometimes they drink tea together.',
		        'But only in the dark.',
		    ];
		    $randMember = function($arr) {
		        return $arr[array_rand($arr)];
		    };
		    return
		        $randMember($coreDevs).' looks like '.
		        $randMember($coreDevs).'. '.
		        $randMember($endingPhrases);
		}
		]
	],
	...
	'components'=>[
	...
	],
	...
```

How it works
------------

[](#how-it-works)

When `Application::EVENT_BEFORE_REQUEST` happens, the probability is being calculated. If, by probability, it is not time to run - nothing happens. If it is time to run:

- In case of `WebApplication`, the `data` attribute of response is set, then the response is sent.
- In case of `ConsoleApplication` the output is echoed, then the the application execution ends.

Advanced generator usage
------------------------

[](#advanced-generator-usage)

You can return objects and arrays in generators. In case of `ConsoleApplication`, they will be displayed via `print_r`. In case of `WebApplication` the result would depend on what format you are trying to output generator's result in. For example, you might be getting error with array and object without \_\_toString() implementation in case of `html` format.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3908d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c53a3bd47504ecf015853565657a1d1b129a392c88ed5d324f0544801baa2f3?d=identicon)[tebazil](/maintainers/tebazil)

---

Top Contributors

[![vambus](https://avatars.githubusercontent.com/u/2419721?v=4)](https://github.com/vambus "vambus (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tebazil-yii2-vodka-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/tebazil-yii2-vodka-behavior/health.svg)](https://phpackages.com/packages/tebazil-yii2-vodka-behavior)
```

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
