Download the PHP package marwanalsoltany/amqp-agent without Composer

On this page you can find all versions of the php package marwanalsoltany/amqp-agent. 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 amqp-agent

AMQP Agent

An elegant wrapper around the famous php-amqplib for 90% use case. [![PHP Version][php-icon]][php-href] [![Latest Version on Packagist][version-icon]][version-href] [![License][license-icon]][license-href] [![Maintenance][maintenance-icon]][maintenance-href] [![Documentation][documentation-icon]][documentation-href] [![Total Downloads][downloads-icon]][downloads-href] [![Scrutinizer Build Status][scrutinizer-icon]][scrutinizer-href] [![Scrutinizer Code Coverage][scrutinizer-coverage-icon]][scrutinizer-coverage-href] [![Scrutinizer Code Quality][scrutinizer-quality-icon]][scrutinizer-quality-href] [![Travis Build Status][travis-icon]][travis-href] [![StyleCI Code Style][styleci-icon]][styleci-href]
Table of Contents

[Installation](#installation)
[About AMQP Agent](#about-amqp-agent)
[API](#api)
Documentation
[Configuration](#configuration)
[Examples](#examples)
[Links](#links)
[License](#license)
[Changelog](./CHANGELOG.md)

Tweet

Key Features

  1. Framework agnostic, integrates easily in any codebase
  2. An intuitive and tested API with out-of-the-box support for Publishers, Consumers, and RPC Endpoints
  3. Contains tons of helpers to get you up and running in no time without deep knowledge of the topic
  4. Unlimited flexibility when it comes to customizing it to your exact needs
  5. Actively maintained, well documented and all about syntactic sugar.

Installation

Try AMQP Agent out now:

Composer using Packagist:

Composer using GitHub Repo (unstable):

Copy this configuration in your composer.json:

Run:

#ff6347 Note: AMQP Agent supports now PHP 7.1 by default starting from version v1.1.1, if you used the php7.1-compatibility branch in older versions, update your composer.json!


About AMQP Agent

AMQP Agent tries to simplify the implementation of a message-broker in a PHP project. It takes away the entire overhead of building and configuring objects or creating classes that you would need in order to talk with RabbitMQ server (through php-amqplib) and exposes a tested, fully configurable, and flexible API that fits almost any project.

The php-amqplib library is awesome and works very well. The one and only problem is, it's pretty bare-bone to be used in a project, without remaking your own wrapper classes, it's almost impossible to not write spaghetti code. Plus the enormous amount of functions, methods, and configurations (parameters) that come with it make it really hard to implement a reasonable API to be used. AMQP Agent solves this problem by making as much abstraction as possible without losing control over the workers and by bringing back the terminology associated with message-brokers, a Publisher and a Consumer is all that you need to deal with if you are a newcomer.

According to this motto, AMQP Agent makes working with RabbitMQ as fun and elegant as possible by exposing some fluent interfaces that are cleverly implemented, fit modern PHP development, nice to work with and very simple to use; yet very powerful and can overwrite the smallest quirks at any point of working with the worker. With AMQP Agent you can start publishing and consuming messages with just a few lines of code!

AMQP Agent does not overwrite anything of php-amqplib nor it does change the terminology associated with its functions. It only simplifies it; takes out the noise of functions' names and extends it in some places. It also adds some nice features like workers-commands, dynamic channel-waiting, and facilitation methods.

AMQP Agent does also offer a powerful event-based RPC Client and RPC Server for your IoT projects.

Working with AMQP Agent can be as easy as:


API

AMQP Agent exposes a number of concrete classes that can be directly used and other abstract classes that can be extended. These two class-variants also have a helper sub-division.

AMQP Agent Classes

Class Description API
AbstractWorker *A An abstract class implementing the basic functionality of a worker. Doc
Publisher C\S A class specialized in publishing. Implementing only the methods needed for a publisher. Doc
Consumer C\S A class specialized in consuming. Implementing only the methods needed for a consumer. Doc
AbstractEndpoint *A An abstract class implementing the basic functionality of an endpoint. Doc
ClientEndpoint *C A class specialized in requesting. Implementing only the methods needed for a client. Doc
ServerEndpoint *C A class specialized in responding. Implementing only the methods needed for a server. Doc
AmqpAgentParameters C\H A class that contains all AMQP Agent parameters as constants. Doc
Utility C\H A class containing miscellaneous helper functions. Doc
Event C\H A simple class for handling events (dispatching and listening). Doc
ArrayProxy C\H A class containing methods for for manipulating and working arrays. Doc
ClassProxy C\H A class containing methods for proxy methods calling, properties manipulation, and class utilities. Doc
IDGenerator C\H A class containing functions for generating unique IDs and Tokens Doc
Serializer C\H A flexible serializer to be used in conjunction with the workers. Doc
Logger C\H A class to write logs, exposing methods that work statically and on instantiation. Doc
Singleton A\H An abstract class implementing the fundamental functionality of a singleton. Doc
Config C\R A class that turns the configuration file into an object. Doc
Client C\R A class returns everything AMQP Agent has to offer. A simple service container so to say. Doc
Example A\H An abstract class used as a default callback for the consumer. Doc

See also: AbstractWorkerSingleton, PublisherSingleton, ConsumerSingleton, AbstractWorkerInterface, PublisherInterface, ConsumerInterface, WorkerFacilitationInterface, WorkerMutationTrait, WorkerCommandTrait, AbstractEndpointInterface, ClientEndpointInterface, ServerEndpointInterface, EventTrait, ArrayProxyTrait, ClassProxyTrait, AbstractParameters.

Bibliography

#ff6347 Note: Singleton is considered an anti-pattern, try avoiding it as much as possible, though there are use-cases for it. Use singletons only if you know what you are doing.


Configuration

If you just quickly want to publish and consume messages, everything is ready and configured already, AMQP Agent is shipped with a tested configuration that follows best practices. You can simply import Publisher class and/or Consumer class in your file and overwrite the parameters you want (RabbitMQ credentials for example) later on the instance.

If you want to fine-tune and tweak AMQP Agent configuration to your exact needs, there is a bit of work to do. You have to supply a config file (see: maks-amqp-agent-config.php and pay attention to the comments). You don't have to supply everything, you can simply only write the parameters you want to overwrite, AMQP Agent is smart enough to append the deficiency. These parameters can also be overwritten later through public assignment notation or per method call.

#1e90ff Fact: AMQP Agent uses the same parameter names as php-amqplib in the config file and in the parameters array passed on the method call.

Here is an example of a config file

#ff6347 Note: Array first-level key names (suffixed with Options) are specific to AMQP Agent.


Examples

Before we start with examples, we have to clarify a few things. It's worth mentioning from the beginning that with AMQP Agent there are multiple ways to how you can retrieve a worker, there is the simple way, the recommended way, and the more advanced ways. After you retrieve a worker, it's like clay, you can form it the way you want. This modular design gracefully accommodates your needs, drives to a scalable codebase, and simply makes everyone happy.

The ways a worker can be retrieved

  1. The simplest way is to instantiate a worker directly i.e. using new keyword. This way requires passing parameters via the constructor, method calls, or public property assignment.
  2. The more advanced way is retrieving a singleton worker i.e PublisherSingleton::getInstance(). This way requires passing parameters via getInstance() method, method calls, or public property assignment.
  3. The more advanced but recommended way is to use an instance of the Client class. This way also makes code more readable as the parameters are retrieved from the passed config.

Here are some examples of a publisher

  1. Variant I: Passing parameters in worker's constructor.

  2. Variant II: Overwriting parameters per method call.

Here are some examples of a consumer

  1. Variant I: Passing parameters in worker's constructor.

  2. Variant II: Overwriting parameters per method call.

Here are some examples of an RPC client

  1. Variant I: Passing parameters in client's constructor.

  2. Variant II: Overwriting parameters per method call.

Here are some examples of an RPC server

  1. Variant I: Passing parameters in server's constructor.

  2. Variant II: Overwriting parameters per method call.

#1e90ff Fact: When supplying parameters provide only the parameters you need. AMQP Agent is smart enough to append the deficiency.

#32cd32 Advice: You can simplify the heavy constructors written in the examples above if you use get($className) on an instance of the Client class after providing a config file with the parameters you want.

#ff6347 Note: Refer to AMQP Agent Docs for the full explanation of the methods. Refer to RabbitMQ Documentation and php-amqplib for the full explanation of the parameters.

Advanced Examples

In these examples, you will see how you would work with AMQP Agent in a real-world scenario.

#1e90ff Fact: You can make the code in Publisher/Consumer Advanced Examples way more easer if you make all parameters' changes in a config file and pass it to the client instead of the default.

#32cd32 Advice: AMQP Agent code-base is well documented, please refer to this link to have a look over all classes and methods.


Links


License

AMQP Agent is an open-sourced package licensed under the php-amqplib license.
Copyright (c) 2020 Marwan Al-Soltany. All rights reserved.


All versions of amqp-agent with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
php-amqplib/php-amqplib Version ^3.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 marwanalsoltany/amqp-agent contains the following files

Loading the files please wait ....