PHPackages                             digitalnoise/command-launcher-bundle - 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. digitalnoise/command-launcher-bundle

ActiveSymfony-bundle[CLI &amp; Console](/categories/cli)

digitalnoise/command-launcher-bundle
====================================

0.1.0(1y ago)01.9kMITPHPPHP &gt;=8.1

Since Feb 18Pushed 1y ago2 watchersCompare

[ Source](https://github.com/digitalnoise-de/command-launcher-bundle)[ Packagist](https://packagist.org/packages/digitalnoise/command-launcher-bundle)[ RSS](/packages/digitalnoise-command-launcher-bundle/feed)WikiDiscussions main Synced 1mo ago

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

digitalnoise CommandLauncherBundle
==================================

[](#digitalnoise-commandlauncherbundle)

---

[![Total Downloads](https://camo.githubusercontent.com/cd0a57ec5ccb8adce5f10c5f7ef3087ea2be740ca421aed16f5241415644f447/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6469676974616c6e6f6973652f636f6d6d616e642d6c61756e636865722d62756e646c652e737667)](https://packagist.org/packages/digitalnoise/command-launcher-bundle)[![MIT License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](https://packagist.org/packages/digitalnoise/command-launcher-bundle)

This bundle provides functionality to execute any message (or command) of an application which has messenger based structure, using the Symfony CLI. An example for such applications would be one, that makes use of the [symfony/messenger](https://github.com/symfony/messenger) or something similar (as long as you use a structure, that passes a message to a bus which calls a separate handler, it works).

### What is this bundle for?

[](#what-is-this-bundle-for)

Imagine a REST-Controller which passes a message to the injected messenger.

```
// ...
class ActivateUserController
{
    // ...
    public function __invoke(Request $request): Response
    {
        $userId = UserId::fromRequest($request);
        $message = new ActivateUserMessage(UserId $id)

        $this->messageBus->dispatch($message);

        // ...
    }
}
```

This is a pretty simple example, but this will lead us to the point. Let's assume, that this route cannot be used for some abstract reason, but you need to activate a user immediately. Of course, you can write a small cli command and execute it afterwards. But there could be much more complex cases. Those could make it useful, to have the possibility, to pass those messages directly to the message bus.

This bundle provides the possibility to execute those commands from the cli without writing separate commands for each case.

Simply by calling:

```
bin/console digitalnoise:command:launch

```

This will provide a list of commands/messages.

```
[ActivateUser   ] Acme\Message\ActivateUser
[DeleteUser     ] Acme\Message\DeleteUser
[CreateSomething] Acme\Message\CreateSomething
> ActivateUser

```

After choosing an option (e.g., ActivateUser), you can pass the required parameter to the message. The list will look as the list above, just with your provided user ids with the related information (it's up to you, how they'll look like).

Setup
-----

[](#setup)

---

### Installation

[](#installation)

Using this package is similar to all Symfony bundles. The following steps must be performed

1. Download the bundle
2. Enable the bundle

### Step 1: Download the bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory, and execute the following command to download the latest stable version of this bundle and add it as a dependency to your project:

```
composer require digitalnoise/command-launcher-bundle

```

### Step 2: Enable the bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding new Digitalnoise\\CommandLauncherBundle\\CommandLauncherBundle() to the bundles array of the registerBundles function in your project's app/AppKernel.php file:

```
