Download the PHP package think-codee/laravel-command-bus without Composer

On this page you can find all versions of the php package think-codee/laravel-command-bus. 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 laravel-command-bus

Laravel Command Bus

This package provides a simple and efficient way to implement the command pattern in your Laravel applications, allowing for better separation of concerns and more maintainable code.

Installation

Install with composer:

Optionally, you can publish the config file with:

Below is the configuration file content:

Usage

This package allows you to create and manage multiple command buses, providing a robust and flexible system for handling different types of commands within your Laravel application. It is especially useful when implementing architectural patterns like CQRS (Command and Query Responsibility Segregation), which separates read and update operations. Each bus can be configured with its own set of middlewares and handler resolvers, enhancing the modularity and organization of your application.

Defining buses

To create a bus, start by defining an interface:

Next, create a class that implements this interface:

You may use the following artisan command to create a bus:

Each bus must be registered in the configuration file. The package will bind the interface to the corresponding class and assign it an alias:

You can then use the bus in your application as follows:

Defining commands and handlers

To define a command:

To define a handler for the command:

You may use the following artisan command to create a command with handler:

Defining middleware

In this package, middleware works similarly to standard Laravel middlewares. They allow you to run code before or after a command is handled, providing a way to add common behavior to your command handling logic.

To define a middleware, create a class that processes the command before and/or after it is handled:

Registering middleware

You can register middleware to specific command handlers using attributes:

You can still register middlewares in the configuration file, assigning them to specific buses. The middleware will be applied to all commands processed by the bus.

Handler resolvers

Each bus has a handler resolver that determines how to resolve the appropriate handler for a given command. The resolver and the method used to handle the command are specified in the configuration file for each bus:

Every handler resolver must implement the HandlerResolver interface. The SuffixHandlerResolver comes by default with the package. If you have a command named TestCommand.php, it will try to resolve the handler name as TestCommandHandler.php in the same directory.

When a command is run through the resolved handler, it will try to use the method specified in the configuration file.

Specifying a Handler for a Specific Command

You can also set a specific handler for a command using the #[Handler] attribute. The second parameter is optional and specifies the method name to be used. If not specified, the method name from the configuration file will be used.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Running Tests

To run tests, run the following command


All versions of laravel-command-bus with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^11.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 think-codee/laravel-command-bus contains the following files

Loading the files please wait ....