PHPackages                             beryllium/llama - 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. [CLI &amp; Console](/categories/cli)
4. /
5. beryllium/llama

ActiveLibrary[CLI &amp; Console](/categories/cli)

beryllium/llama
===============

Llama Commander lets you use anonymous functions as console commands via the Symfony Console Component.

0.3.1(9y ago)196[1 issues](https://github.com/beryllium/llama/issues)MITPHP

Since Oct 17Pushed 9y ago2 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (6)Used By (0)

Llama Commander
---------------

[](#llama-commander)

[![Build Status](https://camo.githubusercontent.com/c7a9f0489079b1aa1a655d4504190d637469f7654bdbd755fda60c38a09be6f5/68747470733a2f2f7472617669732d63692e6f72672f626572796c6c69756d2f6c6c616d612e737667)](https://travis-ci.org/beryllium/llama)

Llama Commander lets you use anonymous functions as console commands via the Symfony Console Component.

Why does it exist?
------------------

[](#why-does-it-exist)

Llama Commander allows developers to define Symfony Console Commands inline instead of having to create a class for each command. When developers are using the Console in a microframework or no-framework context, they may benefit from this flexibility.

What is the spec?
-----------------

[](#what-is-the-spec)

The class **LlamaCommand** takes the following parameters:

- **$name**: The name for the command (optional on instantiation, but must be set in the constructor or via the -&gt;setName() or -&gt;configure() methods before the command can be invoked)
- **$configurator**: An optional callable function to configure the command. This can be used to set the Description, Options, and Arguments for the console command.
- **$executor**: The core logic for the console command. This callable will receive the input and return the output at the core of the console command being written.
- **$interactor**: An optional callable that defines user interaction logic.
- **$initializer**: An optional callable that initializes parameters before interaction and execution.

How do I use it?
----------------

[](#how-do-i-use-it)

When you initialize a new `LlamaCommand`, you pass it at minimum a name (string) and an "Executor" lambda (callable) that determines what the command does. You can also pass it a Configurator, an Initializer, or an Interactor.

```
$app     = new Application;        // Silex application
$console = new ConsoleApplication; // Symfony console component

/* ... extra application setup, defining the pheanstalk service, etc ... */

$console->add(new Beryllium\Llama\LlamaCommand(
    'queue:listen',     // Start a queue listener
    null,               // No configuration at this time
    function ($input, $output) use ($app, $console) {
        do {
            $job = $app['pheanstalk']
              ->watch('testtube')
              ->ignore('default')
              ->reserve();

            $output->writeln('Raw data: ' . $job->getData());
            $app['pheanstalk']->delete($job);
        } while (strtolower($job->getData()) !== 'halt');
    }
));

$console->run();
```

If your command needs to have options or arguments, you can specify an anonymous Configurator function for that:

```
$console->add(new Beryllium\Llama\LlamaCommand(
    'queue:listen',     // Start a queue listener
    function ($config) use ($app, $console) {
        $config->setDescription('Listen for stuff to do')
               ->addArgument(
                   'items',
                   InputArgument::OPTIONAL,
                   'How much stuff to listen for'
               );
    },
    function ($input, $output) use ($app, $console) {
        // ... command code goes here
    }
));
```

If you want your code to be more precise, you can also typehint the main lambda. This will help your IDE give you hints about how to interact with $input and $output:

```
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

$app     = new Application;        // Silex application
$console = new ConsoleApplication; // Symfony console component

/* ... extra application setup ... */

$console->add(new Beryllium\Llama\LlamaCommand(
    'queue:listen',     // Start a queue listener
    null,               // No configuration at this time
    function (InputInterface $input, OutputInterface $output) use ($app, $console) {
        // ... now $input and $output are type-hinted
    }
));

$console->run();
```

Combining the above examples, you would register the command with the console application like so:

```
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

$app     = new Application;        // Silex application
$console = new ConsoleApplication; // Symfony console component

/* ... extra application setup, defining the pheanstalk service, etc ... */

$console->add(new Beryllium\Llama\LlamaCommand(
    'queue:listen',
    function ($config) use ($app, $console) {
        $config->setDescription('Listen for stuff to do')
               ->addArgument(
                   'items',
                   InputArgument::OPTIONAL,
                   'How much stuff to listen for'
               );
    },
    function (InputInterface $input, OutputInterface $output) use ($app, $console) {
        $pheanstalk = $app['pheanstalk'];

        do {
            $job = $pheanstalk
              ->watch('testtube')
              ->ignore('default')
              ->reserve();

            $output->writeln('Raw data: ' . $job->getData());
            $pheanstalk->delete($job);
        } while (strtolower($job->getData()) !== 'halt');
    }
));

$console->run();
```

And that's all for now. If you would like to learn more about how to use the Symfony Console Component, the Symfony website has a [very helpful documentation page about it](http://symfony.com/doc/current/components/console/introduction.html).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% 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

Every ~71 days

Total

5

Last Release

3582d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/602491?v=4)[Kevin Boyd](/maintainers/beryllium)[@beryllium](https://github.com/beryllium)

---

Top Contributors

[![beryllium](https://avatars.githubusercontent.com/u/602491?v=4)](https://github.com/beryllium "beryllium (14 commits)")[![kdrdmr](https://avatars.githubusercontent.com/u/1982940?v=4)](https://github.com/kdrdmr "kdrdmr (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/beryllium-llama/health.svg)

```
[![Health](https://phpackages.com/badges/beryllium-llama/health.svg)](https://phpackages.com/packages/beryllium-llama)
```

###  Alternatives

[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[crazywhalecc/static-php-cli

Build single static PHP binary, with PHP project together, with popular extensions included.

1.8k13.9k](/packages/crazywhalecc-static-php-cli)[matthiasnoback/symfony-console-form

Use Symfony forms for Console command input

368264.8k8](/packages/matthiasnoback-symfony-console-form)[phpcr/phpcr-shell

Shell for PHPCR

721.3M8](/packages/phpcr-phpcr-shell)[madewithlove/license-checker

CLI tool to verify allowed licenses for composer dependencies

54449.8k21](/packages/madewithlove-license-checker)[shel/neos-terminal

Neos CMS Ui terminal for running Eel expressions and other commands

1441.3k](/packages/shel-neos-terminal)

PHPackages © 2026

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