Download the PHP package digitalnoise/command-launcher-bundle without Composer

On this page you can find all versions of the php package digitalnoise/command-launcher-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package command-launcher-bundle

digitalnoise CommandLauncherBundle


Total Downloads MIT License

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 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?

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

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


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

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

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:

Using the bundle


You need to take care for the following interfaces and classes, to make this bundle work:

Digitalnoise\CommandLauncher\CommandProvider
Digitalnoise\CommandLauncher\CommandLauncher
Digitalnoise\CommandLauncher\ParameterResolver

Digitalnoise\CommandLauncher\ParameterOption

1. The CommandProvider interface

The function all() will gather all commands inside your application which will be passed to the message bus. Since any application has its own structure and messenger service, you need to implement this function individually.

2. The CommandLauncher interface

This interface is responsible for the execution of a message. The implentation will take a message bus as class parameter. The launch(object $command) function will receive a message and pass it to the used bus inside your application.

3. The abstract ParameterResolver

Let's call the upper example with the user activation to mind. Here, we don't pass a string to the message, but rather an object of the class UserId.

By implementing supports(string $class), you provide the information, for which type of parameter, this resolver shall be called. In case of the UserId class, it would look as follows:

As you want to choose, which user will be activated, you need to provide options. The following code shows an example, how the implementation could look like.

All user objects will be loaded and transformed to a list of ParameterOption objects.

Finally, you need to define the actual value, which will be returned by choosing a user option, when using the command.

Let's ignore the fact, that the user will be fetched inspite of being so some seconds before. It's your choice, how you want to hold the data inside your UserIdProvider class. This is the value, which is actually passed to the message, when it's built.

Since the last update, it is possible to define a manual input value. In the case, that an option won't be listed for any unexpected reason, you can type a custom value and this one will be process inside the manualValue function. The option will be listed by default, but the implementation, how the manual input will be used, is up to you.

Bring it all together and use the command


Your services.yml could look like this. In this example, we assume, that the thephpleague/tactician command bus is used.

With the configuration above, we should have brought together the necessary classes and information to execute the command by typing

bin/console digitalnoise:command:launch

All versions of command-launcher-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
digitalnoise/command-launcher Version ^0.1
symfony/framework-bundle Version ^5.4|^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package digitalnoise/command-launcher-bundle contains the following files

Loading the files please wait ....