├── .gitattributes ├── CHANGELOG.md ├── LICENSE.txt ├── README.md ├── bin ├── humus-amqp-module ├── humus-amqp-module.bat └── humus-amqp-module.php ├── composer.json ├── config └── module.config.php └── src ├── Container └── CliFactory.php └── Module.php /.gitattributes: -------------------------------------------------------------------------------- 1 | /docs export-ignore 2 | /tests export-ignore 3 | .coveralls.yml export-ignore 4 | .docheader export-ignore 5 | .gitignore export-ignore 6 | .php_cs export-ignore 7 | .travis.yml export-ignore 8 | phpunit.xml.dist export-ignore 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [v2.0.0](https://github.com/prolic/HumusAmqpModule/tree/v2.0.0) 4 | 5 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v1.1.0...v2.0.0) 6 | 7 | **Implemented enhancements:** 8 | 9 | - Require PHP 7.4 and HumusAMQP 2.0 [\#46](https://github.com/prolic/HumusAmqpModule/pull/46) ([prolic](https://github.com/prolic)) 10 | 11 | ## [v1.1.0](https://github.com/prolic/HumusAmqpModule/tree/v1.1.0) (2019-03-21) 12 | 13 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v1.0.0...v1.1.0) 14 | 15 | **Closed issues:** 16 | 17 | - Migration from ZF2 to ZF3 [\#43](https://github.com/prolic/HumusAmqpModule/issues/43) 18 | - Use case for possible improvement [\#41](https://github.com/prolic/HumusAmqpModule/issues/41) 19 | 20 | **Merged pull requests:** 21 | 22 | - Updated dependencies [\#44](https://github.com/prolic/HumusAmqpModule/pull/44) ([thomasvargiu](https://github.com/thomasvargiu)) 23 | 24 | ## [v1.0.0](https://github.com/prolic/HumusAmqpModule/tree/v1.0.0) (2016-08-14) 25 | 26 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.3.1...v1.0.0) 27 | 28 | ## [v0.3.1](https://github.com/prolic/HumusAmqpModule/tree/v0.3.1) (2016-07-04) 29 | 30 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.3.0...v0.3.1) 31 | 32 | ## [v0.3.0](https://github.com/prolic/HumusAmqpModule/tree/v0.3.0) (2016-06-23) 33 | 34 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v1.0.0-BETA.1...v0.3.0) 35 | 36 | ## [v1.0.0-BETA.1](https://github.com/prolic/HumusAmqpModule/tree/v1.0.0-BETA.1) (2016-06-19) 37 | 38 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.2.0...v1.0.0-BETA.1) 39 | 40 | **Implemented enhancements:** 41 | 42 | - RpcServer Response handling [\#39](https://github.com/prolic/HumusAmqpModule/issues/39) 43 | 44 | **Closed issues:** 45 | 46 | - Update documentation for listener configuration [\#25](https://github.com/prolic/HumusAmqpModule/issues/25) 47 | 48 | ## [v0.2.0](https://github.com/prolic/HumusAmqpModule/tree/v0.2.0) (2016-05-27) 49 | 50 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.1.8...v0.2.0) 51 | 52 | **Implemented enhancements:** 53 | 54 | - ZF3 compatibility [\#38](https://github.com/prolic/HumusAmqpModule/pull/38) ([thomasvargiu](https://github.com/thomasvargiu)) 55 | 56 | **Fixed bugs:** 57 | 58 | - Add Zend-Log dependency [\#32](https://github.com/prolic/HumusAmqpModule/issues/32) 59 | 60 | **Closed issues:** 61 | 62 | - Socket Error uncaught exception when trying to consume messages [\#35](https://github.com/prolic/HumusAmqpModule/issues/35) 63 | - Give the opportunity to use another client to communicate with RabbitMQ [\#28](https://github.com/prolic/HumusAmqpModule/issues/28) 64 | - Consumer should return an object/value that can be checked as result [\#27](https://github.com/prolic/HumusAmqpModule/issues/27) 65 | - Add basic integration tests and release BETA 1 [\#15](https://github.com/prolic/HumusAmqpModule/issues/15) 66 | 67 | **Merged pull requests:** 68 | 69 | - PSR 3 Log [\#37](https://github.com/prolic/HumusAmqpModule/pull/37) ([thomasvargiu](https://github.com/thomasvargiu)) 70 | - PHP 7 compatibility and tests [\#36](https://github.com/prolic/HumusAmqpModule/pull/36) ([thomasvargiu](https://github.com/thomasvargiu)) 71 | 72 | ## [v0.1.8](https://github.com/prolic/HumusAmqpModule/tree/v0.1.8) (2016-04-13) 73 | 74 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.1.7...v0.1.8) 75 | 76 | ## [v0.1.7](https://github.com/prolic/HumusAmqpModule/tree/v0.1.7) (2016-04-04) 77 | 78 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.1.6...v0.1.7) 79 | 80 | ## [v0.1.6](https://github.com/prolic/HumusAmqpModule/tree/v0.1.6) (2016-04-01) 81 | 82 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.1.5...v0.1.6) 83 | 84 | ## [v0.1.5](https://github.com/prolic/HumusAmqpModule/tree/v0.1.5) (2016-04-01) 85 | 86 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.1.4...v0.1.5) 87 | 88 | **Merged pull requests:** 89 | 90 | - Compatibility for zend framework 2.5.3 [\#34](https://github.com/prolic/HumusAmqpModule/pull/34) ([ZhaoVitapublic](https://github.com/ZhaoVitapublic)) 91 | 92 | ## [v0.1.4](https://github.com/prolic/HumusAmqpModule/tree/v0.1.4) (2016-01-11) 93 | 94 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.1.3...v0.1.4) 95 | 96 | ## [v0.1.3](https://github.com/prolic/HumusAmqpModule/tree/v0.1.3) (2016-01-11) 97 | 98 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.1.2...v0.1.3) 99 | 100 | ## [v0.1.2](https://github.com/prolic/HumusAmqpModule/tree/v0.1.2) (2016-01-08) 101 | 102 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.1.1...v0.1.2) 103 | 104 | **Merged pull requests:** 105 | 106 | - Fix pcntl typo [\#29](https://github.com/prolic/HumusAmqpModule/pull/29) ([fntlnz](https://github.com/fntlnz)) 107 | 108 | ## [v0.1.1](https://github.com/prolic/HumusAmqpModule/tree/v0.1.1) (2015-10-14) 109 | 110 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/v0.1.0...v0.1.1) 111 | 112 | **Implemented enhancements:** 113 | 114 | - Add automatic serialization / encoding for publishers / consumers [\#16](https://github.com/prolic/HumusAmqpModule/issues/16) 115 | 116 | **Closed issues:** 117 | 118 | - unable to get service locator from inside callback function [\#30](https://github.com/prolic/HumusAmqpModule/issues/30) 119 | - Add events on Consumer and RpcServer [\#22](https://github.com/prolic/HumusAmqpModule/issues/22) 120 | 121 | ## [v0.1.0](https://github.com/prolic/HumusAmqpModule/tree/v0.1.0) (2014-11-10) 122 | 123 | [Full Changelog](https://github.com/prolic/HumusAmqpModule/compare/489b5211bcfb579b33c956d31afd5262c0944bc6...v0.1.0) 124 | 125 | **Fixed bugs:** 126 | 127 | - Wait timeout glitch for consumers with more than one queue [\#17](https://github.com/prolic/HumusAmqpModule/issues/17) 128 | 129 | **Closed issues:** 130 | 131 | - Sometimes a single consumer uses 2 channels [\#12](https://github.com/prolic/HumusAmqpModule/issues/12) 132 | - Exception during flush deffered leads to permanently requeued messages [\#11](https://github.com/prolic/HumusAmqpModule/issues/11) 133 | - implement Publisher confirms [\#10](https://github.com/prolic/HumusAmqpModule/issues/10) 134 | - implement Validated User ID [\#9](https://github.com/prolic/HumusAmqpModule/issues/9) 135 | - Start consumer --without-signals [\#8](https://github.com/prolic/HumusAmqpModule/issues/8) 136 | - Add error callback for consumers [\#7](https://github.com/prolic/HumusAmqpModule/issues/7) 137 | - Add logger configuration [\#6](https://github.com/prolic/HumusAmqpModule/issues/6) 138 | - Put connect\(\) call into initializer [\#5](https://github.com/prolic/HumusAmqpModule/issues/5) 139 | - Move ConsumerInterface into Consumer implementation [\#1](https://github.com/prolic/HumusAmqpModule/issues/1) 140 | 141 | **Merged pull requests:** 142 | 143 | - Exchangespec fix [\#24](https://github.com/prolic/HumusAmqpModule/pull/24) ([prolic](https://github.com/prolic)) 144 | - Fix consumer signal handler [\#21](https://github.com/prolic/HumusAmqpModule/pull/21) ([thomasvargiu](https://github.com/thomasvargiu)) 145 | - test prebuild amqp extension from travis [\#20](https://github.com/prolic/HumusAmqpModule/pull/20) ([prolic](https://github.com/prolic)) 146 | - add tests [\#19](https://github.com/prolic/HumusAmqpModule/pull/19) ([prolic](https://github.com/prolic)) 147 | - Wait timeout glitch for consumers with more than one queue [\#18](https://github.com/prolic/HumusAmqpModule/pull/18) ([prolic](https://github.com/prolic)) 148 | - Fixed flush callback array access [\#4](https://github.com/prolic/HumusAmqpModule/pull/4) ([doalex](https://github.com/doalex)) 149 | - \[WIP\] Refactoring towards ext-amp incl. new features [\#3](https://github.com/prolic/HumusAmqpModule/pull/3) ([prolic](https://github.com/prolic)) 150 | 151 | 152 | 153 | \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* 154 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2020 Sascha-Oliver Prolic 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 4 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation 5 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 6 | to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 9 | Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 12 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 13 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 14 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Humus AMQP Module 2 | ================= 3 | 4 | [![Build Status](https://travis-ci.org/prolic/HumusAmqpModule.svg)](https://travis-ci.org/prolic/HumusAmqpModule) 5 | [![Coverage Status](https://coveralls.io/repos/github/prolic/HumusAmqpModule/badge.svg?branch=master)](https://coveralls.io/github/prolic/HumusAmqpModule?branch=master) 6 | [![Documentation Status](https://readthedocs.org/projects/humusamqp/badge/?version=latest)](https://readthedocs.org/projects/humusamqp/badge/?version=latest) 7 | [![License](https://poser.pugx.org/prolic/humus-amqp-module/license.svg)](https://packagist.org/packages/prolic/humus-amqp-module) 8 | [![Latest Stable Version](https://poser.pugx.org/prolic/humus-amqp-module/v/stable.svg)](https://packagist.org/packages/prolic/humus-amqp-module) 9 | [![Latest Unstable Version](https://poser.pugx.org/prolic/humus-amqp-module/v/unstable.svg)](https://packagist.org/packages/prolic/humus-amqp-module) 10 | [![Total Downloads](https://poser.pugx.org/prolic/humus-amqp-module/downloads.svg)](https://packagist.org/packages/prolic/humus-amqp-module) 11 | [![Dependency Status](https://www.versioneye.com/php/prolic:humus-amqp-module/dev-master/badge.svg)](https://www.versioneye.com/php/prolic:humus-amqp-module) 12 | 13 | ## About 14 | 15 | The Humus AMQP Module incorporates messaging in your zf2 application via RabbitMQ using [HumusAmqp](https://github.com/prolic/HumusAmqp>), 16 | a PHP 7.4 AMQP libray supporting multiple drivers and providing full-featured Consumer, Producer, and JSON-RPC Client / Server implementations. 17 | 18 | The JSON-RPC part implements JSON-RPC 2.0 Specification. 19 | 20 | Current supported drivers are: php-amqp and PhpAmqpLib. 21 | 22 | If you want to use it without Zend Framework, use [HumusAmqp](https://github.com/prolic/HumusAmqp/) without this module. 23 | 24 | Documentation can be found here: [humusamqp.readthedocs.io](https://humusamqp.readthedocs.io/). 25 | 26 | ## Installation 27 | 28 | You can install prolic/humus-amqp-module via composer by adding "prolic/humus-amqp-module": "^2.0" as requirement to your composer.json. 29 | 30 | You can then enable the module in your config/application.config.php by adding 'HumusAmqpModule' to the 'modules' section. 31 | 32 | ## Support 33 | 34 | - File issues at [https://github.com/prolic/HumusAmqp/issues](https://github.com/prolic/HumusAmqpDemoModule/issues). 35 | - Say hello in the [HumusAmqp gitter](https://gitter.im/prolic/HumusAmqp) chat. 36 | 37 | ## Contribute 38 | 39 | Please feel free to fork and extend existing or add new plugins and send a pull request with your changes! 40 | To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation. 41 | 42 | ## License 43 | 44 | Released under the [MIT](LICENSE.txt). 45 | -------------------------------------------------------------------------------- /bin/humus-amqp-module: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | declare(strict_types=1); 12 | /** 13 | * Copyright (c) 2015-2020. Sascha-Oliver Prolic 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * This software consists of voluntary contributions made by many individuals 28 | * and is licensed under the MIT license. 29 | */ 30 | 31 | use Zend\Mvc\Application; 32 | 33 | \ini_set('display_errors', true); 34 | \chdir(__DIR__); 35 | 36 | $previousDir = '.'; 37 | 38 | while (! \file_exists('config/application.config.php')) { 39 | $dir = \dirname(\getcwd()); 40 | 41 | if ($previousDir === $dir) { 42 | throw new RuntimeException( 43 | 'Unable to locate "config/application.config.php": ' . 44 | 'is DoctrineModule in a subdir of your application skeleton?' 45 | ); 46 | } 47 | 48 | $previousDir = $dir; 49 | \chdir($dir); 50 | } 51 | 52 | if (\is_readable('init_autoloader.php')) { 53 | include_once 'init_autoloader.php'; 54 | } elseif (\file_exists(__DIR__ . '/../vendor/autoload.php')) { 55 | include_once __DIR__ . '/../vendor/autoload.php'; 56 | } elseif (\file_exists(__DIR__ . '/../../../autoload.php')) { 57 | include_once __DIR__ . '/../../../autoload.php'; 58 | } else { 59 | throw new RuntimeException('Error: vendor/autoload.php could not be found. Did you run php composer.phar install?'); 60 | } 61 | 62 | $application = Application::init(include 'config/application.config.php'); 63 | 64 | /* @var $cli \Symfony\Component\Console\Application */ 65 | $cli = $application->getServiceManager()->get('humus_amqp_cli'); 66 | exit($cli->run()); 67 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prolic/humus-amqp-module", 3 | "type": "library", 4 | "description": "AMQP module for Zend Framework 2 to integrate RabbitMQ", 5 | "keywords": ["zf2", "rabbit", "rabbitmq", "queue", "amqp", "humus"], 6 | "homepage": "https://github.com/prolic/HumusAmqpModule", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Sascha-Oliver Prolic", 11 | "email": "saschaprolic@googlemail.com" 12 | } 13 | ], 14 | "require": { 15 | "php": "^7.4", 16 | "prolic/humus-amqp" : "^2.0", 17 | "psr/container": "^1.0", 18 | "sandrokeil/interop-config": "^1.0 || ^2.0", 19 | "symfony/console": "^4.3|^5.0", 20 | "zendframework/zend-modulemanager": "^2.8.4", 21 | "zendframework/zend-mvc": "^2.7.15" 22 | }, 23 | "require-dev": { 24 | "friendsofphp/php-cs-fixer": "^2.16.1", 25 | "phpunit/phpunit": "^9.0", 26 | "prooph/php-cs-fixer-config": "^0.3", 27 | "php-coveralls/php-coveralls": "^2.1" 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "HumusAmqpModule\\": "src/", 32 | "HumusAmqpModuleTest\\": "tests/" 33 | 34 | } 35 | }, 36 | "bin": [ 37 | "bin/humus-amqp-module" 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /config/module.config.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | declare(strict_types=1); 12 | 13 | namespace HumusAmqpModule; 14 | 15 | use Humus\Amqp\Container\DriverFactory; 16 | use Humus\Amqp\Driver\Driver; 17 | 18 | return [ 19 | 'service_manager' => [ 20 | 'factories' => [ 21 | 'humus_amqp_cli' => Container\CliFactory::class, 22 | Driver::class => DriverFactory::class, 23 | ], 24 | ], 25 | ]; 26 | -------------------------------------------------------------------------------- /src/Container/CliFactory.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | declare(strict_types=1); 12 | 13 | namespace HumusAmqpModule\Container; 14 | 15 | use Humus\Amqp\Console\ConsoleRunner; 16 | use Psr\Container\ContainerInterface; 17 | use Symfony\Component\Console\Application; 18 | 19 | final class CliFactory 20 | { 21 | public function __invoke(ContainerInterface $container): Application 22 | { 23 | return ConsoleRunner::createApplication(ConsoleRunner::createHelperSet($container)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Module.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | declare(strict_types=1); 12 | 13 | namespace HumusAmqpModule; 14 | 15 | use Zend\ModuleManager\Feature\ConfigProviderInterface; 16 | 17 | class Module implements ConfigProviderInterface 18 | { 19 | /** 20 | * Get config 21 | * 22 | * @return array|mixed|\Traversable 23 | */ 24 | public function getConfig() 25 | { 26 | return include __DIR__ . '/../config/module.config.php'; 27 | } 28 | } 29 | --------------------------------------------------------------------------------