├── .gitignore ├── App ├── Handler │ ├── SendForgotPasswordEmailHandler.php │ └── SendImportantEmailHandler.php ├── Mailer.php ├── Message │ ├── AbstractMessage.php │ ├── SendForgotPasswordEmail.php │ └── SendImportantEmail.php └── User.php ├── LICENSE ├── README.md ├── bin ├── queue-worker.php └── send-forgot-password-email.php ├── composer.json ├── composer.lock ├── container.php └── queueFactory.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | -------------------------------------------------------------------------------- /App/Handler/SendForgotPasswordEmailHandler.php: -------------------------------------------------------------------------------- 1 | mailer = $mailer; 14 | } 15 | 16 | public function __invoke(SendForgotPasswordEmail $message) 17 | { 18 | $this->mailer->sendMail($message->getUser()->getEmail(), 'subject', 'contents'); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /App/Handler/SendImportantEmailHandler.php: -------------------------------------------------------------------------------- 1 | mailer = $mailer; 14 | } 15 | 16 | public function __invoke(SendForgotPasswordEmail $message) 17 | { 18 | $this->mailer->sendMail($message->getUser()->getEmail(), 'subject', 'contents'); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /App/Mailer.php: -------------------------------------------------------------------------------- 1 | user = $user; 13 | } 14 | 15 | public function getUser() 16 | { 17 | return $this->user; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /App/Message/SendImportantEmail.php: -------------------------------------------------------------------------------- 1 | email = $email; 11 | } 12 | 13 | public function getEmail() 14 | { 15 | return $this->email; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ujjwal Ojha 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # elegant-background-job-php-demo 2 | Demo code for [Elegant background jobs in PHP](https://medium.com/devcupboard/elegant-background-jobs-in-php-c61b91bf582b). 3 | 4 | ## To run queue worker 5 | (forever running program) 6 | ```bash 7 | php bin/queue-worker.php 8 | ``` 9 | 10 | ## To invoke sending message 11 | Open another terminal(or tab) and run: 12 | ```bash 13 | php bin/send-forgot-password-email.php 14 | ``` 15 | 16 | After that, if you see the output of queue worker, you should see something like this: 17 | 18 | ``` 19 | Processing: App\Job\SendForgotPasswordEmail 20 | Processed: App\Job\SendForgotPasswordEmail 21 | ``` 22 | 23 | That's all. The more messages you add to queue, the more processing will be done by the queue worker. 24 | -------------------------------------------------------------------------------- /bin/queue-worker.php: -------------------------------------------------------------------------------- 1 | App\Handler\SendForgotPasswordEmailHandler::class, 25 | App\Message\SendImportantEmail::class 26 | => App\Handler\SendImportantEmailHandler::class, 27 | ]; 28 | 29 | $router = new ClassNameRouter(); 30 | $router->add(Message::class, function(Message $message) use ($handlers, $container) { 31 | $handlerClass = $handlers[$message->getName()]; 32 | $handler = $container->get($handlerClass); 33 | $handler($message); 34 | }); 35 | 36 | $queues = array_map( 37 | function ($queueName) use ($queueFactory) { 38 | return $queueFactory->create($queueName); 39 | }, 40 | $queues 41 | ); 42 | 43 | $eventDispatcher = new EventDispatcher(); 44 | 45 | 46 | $eventDispatcher->addListener( 47 | Bernard\BernardEvents::INVOKE, 48 | function(Bernard\Event\EnvelopeEvent $envelopeEvent) { 49 | echo PHP_EOL . 'Processing: ' . $envelopeEvent->getEnvelope()->getClass(); 50 | } 51 | ); 52 | 53 | $eventDispatcher->addListener( 54 | Bernard\BernardEvents::ACKNOWLEDGE, 55 | function(Bernard\Event\EnvelopeEvent $envelopeEvent) { 56 | echo PHP_EOL . 'Processed: ' . $envelopeEvent->getEnvelope()->getClass(); 57 | } 58 | ); 59 | 60 | $eventDispatcher->addListener( 61 | Bernard\BernardEvents::REJECT, 62 | function(Bernard\Event\RejectEnvelopeEvent $envelopeEvent) { 63 | echo PHP_EOL . 'Failed: ' . $envelopeEvent->getEnvelope()->getClass(); 64 | // you can also log error messages here 65 | } 66 | ); 67 | 68 | // Create a Consumer and start the loop. 69 | $consumer = new Consumer($router, $eventDispatcher); 70 | $consumer->consume(new RoundRobinQueue($queues)); 71 | -------------------------------------------------------------------------------- /bin/send-forgot-password-email.php: -------------------------------------------------------------------------------- 1 | setEmail('foo@bar.com'); 20 | $message = new SendForgotPasswordEmail($user); 21 | 22 | $producer->produce($message, 'emails'); 23 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ojhaujjwal/elegant-background-job-php-demo", 3 | "description": "Elegant background job in PHP demo", 4 | "type": "project", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Ujjwal Ojha", 9 | "email": "bring2uo@gmail.com" 10 | } 11 | ], 12 | "minimum-stability": "dev", 13 | "require": { 14 | "bernard/bernard":"1.0.0-alpha6", 15 | "psr/container": "1.0.*", 16 | "symfony/property-access": "^3.3", 17 | "predis/predis": "^1.1", 18 | "zendframework/zend-servicemanager": "^3.3" 19 | }, 20 | "prefer-stable": true, 21 | "autoload": { 22 | "psr-0": { 23 | "App\\": "./" 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "209eddc307e9d25853b41d06189e2203", 8 | "packages": [ 9 | { 10 | "name": "beberlei/assert", 11 | "version": "v2.7.6", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/beberlei/assert.git", 15 | "reference": "8726e183ebbb0169cb6cb4832e22ebd355524563" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/beberlei/assert/zipball/8726e183ebbb0169cb6cb4832e22ebd355524563", 20 | "reference": "8726e183ebbb0169cb6cb4832e22ebd355524563", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "ext-mbstring": "*", 25 | "php": ">=5.3" 26 | }, 27 | "require-dev": { 28 | "friendsofphp/php-cs-fixer": "^2.1.1", 29 | "phpunit/phpunit": "^4|^5" 30 | }, 31 | "type": "library", 32 | "autoload": { 33 | "psr-4": { 34 | "Assert\\": "lib/Assert" 35 | }, 36 | "files": [ 37 | "lib/Assert/functions.php" 38 | ] 39 | }, 40 | "notification-url": "https://packagist.org/downloads/", 41 | "license": [ 42 | "BSD-2-Clause" 43 | ], 44 | "authors": [ 45 | { 46 | "name": "Benjamin Eberlei", 47 | "email": "kontakt@beberlei.de", 48 | "role": "Lead Developer" 49 | }, 50 | { 51 | "name": "Richard Quadling", 52 | "email": "rquadling@gmail.com", 53 | "role": "Collaborator" 54 | } 55 | ], 56 | "description": "Thin assertion library for input validation in business models.", 57 | "keywords": [ 58 | "assert", 59 | "assertion", 60 | "validation" 61 | ], 62 | "time": "2017-05-04T02:00:24+00:00" 63 | }, 64 | { 65 | "name": "bernard/bernard", 66 | "version": "v1.0.0-alpha6", 67 | "source": { 68 | "type": "git", 69 | "url": "https://github.com/bernardphp/bernard.git", 70 | "reference": "15e2586a2e7bfc745b9325bf8c31130496acdaa0" 71 | }, 72 | "dist": { 73 | "type": "zip", 74 | "url": "https://api.github.com/repos/bernardphp/bernard/zipball/15e2586a2e7bfc745b9325bf8c31130496acdaa0", 75 | "reference": "15e2586a2e7bfc745b9325bf8c31130496acdaa0", 76 | "shasum": "" 77 | }, 78 | "require": { 79 | "beberlei/assert": "~2.1", 80 | "bernard/normalt": "~1.0", 81 | "php": "^5.6 || ^7.0", 82 | "symfony/event-dispatcher": "^2.7|^3.0" 83 | }, 84 | "require-dev": { 85 | "aws/aws-sdk-php": "~2.4|~3.0", 86 | "doctrine/dbal": "~2.3", 87 | "iron-io/iron_mq": "~4.0", 88 | "league/container": "~2.3", 89 | "pda/pheanstalk": "~3.0", 90 | "php-amqplib/php-amqplib": "~2.5", 91 | "phpspec/phpspec": "^2.4", 92 | "phpunit/phpunit": "^5.5|^6.0", 93 | "pimple/pimple": "~1.0", 94 | "predis/predis": "~0.8", 95 | "psr/log": "~1.0", 96 | "queue-interop/amqp-interop": "^0.6", 97 | "queue-interop/queue-interop": "^0.6", 98 | "symfony/console": "^2.7|^3.0", 99 | "symfony/dependency-injection": "^2.7|^3.0" 100 | }, 101 | "suggest": { 102 | "aws/aws-sdk-php": "Allow sending messages to AWS services like Simple Queue Service", 103 | "doctrine/dbal": "Allow sending messages to simulated message queue in a database via doctrine dbal", 104 | "iron-io/iron_mq": "Allow sending messages to IronMQ", 105 | "mongodb/mongodb": "Allow sending messages to a MongoDB server via PHP Driver", 106 | "pda/pheanstalk": "Allow sending messages to Beanstalk using pheanstalk", 107 | "php-amqplib/php-amqplib": "Allow sending messages to an AMQP server using php-amqplib", 108 | "predis/predis": "Allow sending messages to Redis using predis", 109 | "queue-interop/amqp-interop": "Allow sending messages using amqp interop compatible transports", 110 | "queue-interop/queue-interop": "Allow sending messages using queue interop compatible transports" 111 | }, 112 | "type": "library", 113 | "extra": { 114 | "branch-alias": { 115 | "dev-master": "1.0.x-dev" 116 | } 117 | }, 118 | "autoload": { 119 | "psr-4": { 120 | "Bernard\\": "src/" 121 | } 122 | }, 123 | "notification-url": "https://packagist.org/downloads/", 124 | "license": [ 125 | "MIT" 126 | ], 127 | "description": "Message queue abstraction layer", 128 | "homepage": "https://github.com/bernardphp/bernard", 129 | "keywords": [ 130 | "bernard", 131 | "message", 132 | "message queue", 133 | "queue" 134 | ], 135 | "time": "2017-09-15T10:24:09+00:00" 136 | }, 137 | { 138 | "name": "bernard/normalt", 139 | "version": "1.1.0", 140 | "source": { 141 | "type": "git", 142 | "url": "https://github.com/bernardphp/normalt.git", 143 | "reference": "1cde16b1a2a5a20964c3e2fea66e2b98c3f57d41" 144 | }, 145 | "dist": { 146 | "type": "zip", 147 | "url": "https://api.github.com/repos/bernardphp/normalt/zipball/1cde16b1a2a5a20964c3e2fea66e2b98c3f57d41", 148 | "reference": "1cde16b1a2a5a20964c3e2fea66e2b98c3f57d41", 149 | "shasum": "" 150 | }, 151 | "require": { 152 | "symfony/serializer": "^2.3 || ^3.0" 153 | }, 154 | "require-dev": { 155 | "doctrine/common": "^2.1", 156 | "phpspec/phpspec": "^2.5" 157 | }, 158 | "type": "library", 159 | "extra": { 160 | "branch-alias": { 161 | "dev-master": "1.1-dev" 162 | } 163 | }, 164 | "autoload": { 165 | "psr-4": { 166 | "Normalt\\": "src/" 167 | } 168 | }, 169 | "notification-url": "https://packagist.org/downloads/", 170 | "license": [ 171 | "MIT" 172 | ], 173 | "description": "Normalt is a extension to Symfony Serializer that only implements the Normalization part", 174 | "keywords": [ 175 | "denormalization", 176 | "normalization" 177 | ], 178 | "time": "2016-05-03T08:09:59+00:00" 179 | }, 180 | { 181 | "name": "container-interop/container-interop", 182 | "version": "1.2.0", 183 | "source": { 184 | "type": "git", 185 | "url": "https://github.com/container-interop/container-interop.git", 186 | "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8" 187 | }, 188 | "dist": { 189 | "type": "zip", 190 | "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8", 191 | "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8", 192 | "shasum": "" 193 | }, 194 | "require": { 195 | "psr/container": "^1.0" 196 | }, 197 | "type": "library", 198 | "autoload": { 199 | "psr-4": { 200 | "Interop\\Container\\": "src/Interop/Container/" 201 | } 202 | }, 203 | "notification-url": "https://packagist.org/downloads/", 204 | "license": [ 205 | "MIT" 206 | ], 207 | "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", 208 | "homepage": "https://github.com/container-interop/container-interop", 209 | "time": "2017-02-14T19:40:03+00:00" 210 | }, 211 | { 212 | "name": "paragonie/random_compat", 213 | "version": "v2.0.11", 214 | "source": { 215 | "type": "git", 216 | "url": "https://github.com/paragonie/random_compat.git", 217 | "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8" 218 | }, 219 | "dist": { 220 | "type": "zip", 221 | "url": "https://api.github.com/repos/paragonie/random_compat/zipball/5da4d3c796c275c55f057af5a643ae297d96b4d8", 222 | "reference": "5da4d3c796c275c55f057af5a643ae297d96b4d8", 223 | "shasum": "" 224 | }, 225 | "require": { 226 | "php": ">=5.2.0" 227 | }, 228 | "require-dev": { 229 | "phpunit/phpunit": "4.*|5.*" 230 | }, 231 | "suggest": { 232 | "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." 233 | }, 234 | "type": "library", 235 | "autoload": { 236 | "files": [ 237 | "lib/random.php" 238 | ] 239 | }, 240 | "notification-url": "https://packagist.org/downloads/", 241 | "license": [ 242 | "MIT" 243 | ], 244 | "authors": [ 245 | { 246 | "name": "Paragon Initiative Enterprises", 247 | "email": "security@paragonie.com", 248 | "homepage": "https://paragonie.com" 249 | } 250 | ], 251 | "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", 252 | "keywords": [ 253 | "csprng", 254 | "pseudorandom", 255 | "random" 256 | ], 257 | "time": "2017-09-27T21:40:39+00:00" 258 | }, 259 | { 260 | "name": "predis/predis", 261 | "version": "v1.1.1", 262 | "source": { 263 | "type": "git", 264 | "url": "https://github.com/nrk/predis.git", 265 | "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1" 266 | }, 267 | "dist": { 268 | "type": "zip", 269 | "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1", 270 | "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1", 271 | "shasum": "" 272 | }, 273 | "require": { 274 | "php": ">=5.3.9" 275 | }, 276 | "require-dev": { 277 | "phpunit/phpunit": "~4.8" 278 | }, 279 | "suggest": { 280 | "ext-curl": "Allows access to Webdis when paired with phpiredis", 281 | "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" 282 | }, 283 | "type": "library", 284 | "autoload": { 285 | "psr-4": { 286 | "Predis\\": "src/" 287 | } 288 | }, 289 | "notification-url": "https://packagist.org/downloads/", 290 | "license": [ 291 | "MIT" 292 | ], 293 | "authors": [ 294 | { 295 | "name": "Daniele Alessandri", 296 | "email": "suppakilla@gmail.com", 297 | "homepage": "http://clorophilla.net" 298 | } 299 | ], 300 | "description": "Flexible and feature-complete Redis client for PHP and HHVM", 301 | "homepage": "http://github.com/nrk/predis", 302 | "keywords": [ 303 | "nosql", 304 | "predis", 305 | "redis" 306 | ], 307 | "time": "2016-06-16T16:22:20+00:00" 308 | }, 309 | { 310 | "name": "psr/container", 311 | "version": "1.0.0", 312 | "source": { 313 | "type": "git", 314 | "url": "https://github.com/php-fig/container.git", 315 | "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" 316 | }, 317 | "dist": { 318 | "type": "zip", 319 | "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", 320 | "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", 321 | "shasum": "" 322 | }, 323 | "require": { 324 | "php": ">=5.3.0" 325 | }, 326 | "type": "library", 327 | "extra": { 328 | "branch-alias": { 329 | "dev-master": "1.0.x-dev" 330 | } 331 | }, 332 | "autoload": { 333 | "psr-4": { 334 | "Psr\\Container\\": "src/" 335 | } 336 | }, 337 | "notification-url": "https://packagist.org/downloads/", 338 | "license": [ 339 | "MIT" 340 | ], 341 | "authors": [ 342 | { 343 | "name": "PHP-FIG", 344 | "homepage": "http://www.php-fig.org/" 345 | } 346 | ], 347 | "description": "Common Container Interface (PHP FIG PSR-11)", 348 | "homepage": "https://github.com/php-fig/container", 349 | "keywords": [ 350 | "PSR-11", 351 | "container", 352 | "container-interface", 353 | "container-interop", 354 | "psr" 355 | ], 356 | "time": "2017-02-14T16:28:37+00:00" 357 | }, 358 | { 359 | "name": "symfony/event-dispatcher", 360 | "version": "v3.3.10", 361 | "source": { 362 | "type": "git", 363 | "url": "https://github.com/symfony/event-dispatcher.git", 364 | "reference": "d7ba037e4b8221956ab1e221c73c9e27e05dd423" 365 | }, 366 | "dist": { 367 | "type": "zip", 368 | "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d7ba037e4b8221956ab1e221c73c9e27e05dd423", 369 | "reference": "d7ba037e4b8221956ab1e221c73c9e27e05dd423", 370 | "shasum": "" 371 | }, 372 | "require": { 373 | "php": "^5.5.9|>=7.0.8" 374 | }, 375 | "conflict": { 376 | "symfony/dependency-injection": "<3.3" 377 | }, 378 | "require-dev": { 379 | "psr/log": "~1.0", 380 | "symfony/config": "~2.8|~3.0", 381 | "symfony/dependency-injection": "~3.3", 382 | "symfony/expression-language": "~2.8|~3.0", 383 | "symfony/stopwatch": "~2.8|~3.0" 384 | }, 385 | "suggest": { 386 | "symfony/dependency-injection": "", 387 | "symfony/http-kernel": "" 388 | }, 389 | "type": "library", 390 | "extra": { 391 | "branch-alias": { 392 | "dev-master": "3.3-dev" 393 | } 394 | }, 395 | "autoload": { 396 | "psr-4": { 397 | "Symfony\\Component\\EventDispatcher\\": "" 398 | }, 399 | "exclude-from-classmap": [ 400 | "/Tests/" 401 | ] 402 | }, 403 | "notification-url": "https://packagist.org/downloads/", 404 | "license": [ 405 | "MIT" 406 | ], 407 | "authors": [ 408 | { 409 | "name": "Fabien Potencier", 410 | "email": "fabien@symfony.com" 411 | }, 412 | { 413 | "name": "Symfony Community", 414 | "homepage": "https://symfony.com/contributors" 415 | } 416 | ], 417 | "description": "Symfony EventDispatcher Component", 418 | "homepage": "https://symfony.com", 419 | "time": "2017-10-02T06:42:24+00:00" 420 | }, 421 | { 422 | "name": "symfony/inflector", 423 | "version": "v3.3.10", 424 | "source": { 425 | "type": "git", 426 | "url": "https://github.com/symfony/inflector.git", 427 | "reference": "0474dc4d867c7efefd44017f7903465a7f368b6b" 428 | }, 429 | "dist": { 430 | "type": "zip", 431 | "url": "https://api.github.com/repos/symfony/inflector/zipball/0474dc4d867c7efefd44017f7903465a7f368b6b", 432 | "reference": "0474dc4d867c7efefd44017f7903465a7f368b6b", 433 | "shasum": "" 434 | }, 435 | "require": { 436 | "php": "^5.5.9|>=7.0.8" 437 | }, 438 | "type": "library", 439 | "extra": { 440 | "branch-alias": { 441 | "dev-master": "3.3-dev" 442 | } 443 | }, 444 | "autoload": { 445 | "psr-4": { 446 | "Symfony\\Component\\Inflector\\": "" 447 | }, 448 | "exclude-from-classmap": [ 449 | "/Tests/" 450 | ] 451 | }, 452 | "notification-url": "https://packagist.org/downloads/", 453 | "license": [ 454 | "MIT" 455 | ], 456 | "authors": [ 457 | { 458 | "name": "Bernhard Schussek", 459 | "email": "bschussek@gmail.com" 460 | }, 461 | { 462 | "name": "Symfony Community", 463 | "homepage": "https://symfony.com/contributors" 464 | } 465 | ], 466 | "description": "Symfony Inflector Component", 467 | "homepage": "https://symfony.com", 468 | "keywords": [ 469 | "inflection", 470 | "pluralize", 471 | "singularize", 472 | "string", 473 | "symfony", 474 | "words" 475 | ], 476 | "time": "2017-07-29T21:54:42+00:00" 477 | }, 478 | { 479 | "name": "symfony/polyfill-php70", 480 | "version": "v1.5.0", 481 | "source": { 482 | "type": "git", 483 | "url": "https://github.com/symfony/polyfill-php70.git", 484 | "reference": "b6482e68974486984f59449ecea1fbbb22ff840f" 485 | }, 486 | "dist": { 487 | "type": "zip", 488 | "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/b6482e68974486984f59449ecea1fbbb22ff840f", 489 | "reference": "b6482e68974486984f59449ecea1fbbb22ff840f", 490 | "shasum": "" 491 | }, 492 | "require": { 493 | "paragonie/random_compat": "~1.0|~2.0", 494 | "php": ">=5.3.3" 495 | }, 496 | "type": "library", 497 | "extra": { 498 | "branch-alias": { 499 | "dev-master": "1.5-dev" 500 | } 501 | }, 502 | "autoload": { 503 | "psr-4": { 504 | "Symfony\\Polyfill\\Php70\\": "" 505 | }, 506 | "files": [ 507 | "bootstrap.php" 508 | ], 509 | "classmap": [ 510 | "Resources/stubs" 511 | ] 512 | }, 513 | "notification-url": "https://packagist.org/downloads/", 514 | "license": [ 515 | "MIT" 516 | ], 517 | "authors": [ 518 | { 519 | "name": "Nicolas Grekas", 520 | "email": "p@tchwork.com" 521 | }, 522 | { 523 | "name": "Symfony Community", 524 | "homepage": "https://symfony.com/contributors" 525 | } 526 | ], 527 | "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", 528 | "homepage": "https://symfony.com", 529 | "keywords": [ 530 | "compatibility", 531 | "polyfill", 532 | "portable", 533 | "shim" 534 | ], 535 | "time": "2017-06-14T15:44:48+00:00" 536 | }, 537 | { 538 | "name": "symfony/property-access", 539 | "version": "v3.3.10", 540 | "source": { 541 | "type": "git", 542 | "url": "https://github.com/symfony/property-access.git", 543 | "reference": "8d975b77d10ad8c24a7b88af1b38b333d2d4fa4b" 544 | }, 545 | "dist": { 546 | "type": "zip", 547 | "url": "https://api.github.com/repos/symfony/property-access/zipball/8d975b77d10ad8c24a7b88af1b38b333d2d4fa4b", 548 | "reference": "8d975b77d10ad8c24a7b88af1b38b333d2d4fa4b", 549 | "shasum": "" 550 | }, 551 | "require": { 552 | "php": "^5.5.9|>=7.0.8", 553 | "symfony/inflector": "~3.1", 554 | "symfony/polyfill-php70": "~1.0" 555 | }, 556 | "require-dev": { 557 | "symfony/cache": "~3.1" 558 | }, 559 | "suggest": { 560 | "psr/cache-implementation": "To cache access methods." 561 | }, 562 | "type": "library", 563 | "extra": { 564 | "branch-alias": { 565 | "dev-master": "3.3-dev" 566 | } 567 | }, 568 | "autoload": { 569 | "psr-4": { 570 | "Symfony\\Component\\PropertyAccess\\": "" 571 | }, 572 | "exclude-from-classmap": [ 573 | "/Tests/" 574 | ] 575 | }, 576 | "notification-url": "https://packagist.org/downloads/", 577 | "license": [ 578 | "MIT" 579 | ], 580 | "authors": [ 581 | { 582 | "name": "Fabien Potencier", 583 | "email": "fabien@symfony.com" 584 | }, 585 | { 586 | "name": "Symfony Community", 587 | "homepage": "https://symfony.com/contributors" 588 | } 589 | ], 590 | "description": "Symfony PropertyAccess Component", 591 | "homepage": "https://symfony.com", 592 | "keywords": [ 593 | "access", 594 | "array", 595 | "extraction", 596 | "index", 597 | "injection", 598 | "object", 599 | "property", 600 | "property path", 601 | "reflection" 602 | ], 603 | "time": "2017-10-02T06:42:24+00:00" 604 | }, 605 | { 606 | "name": "symfony/serializer", 607 | "version": "v3.3.10", 608 | "source": { 609 | "type": "git", 610 | "url": "https://github.com/symfony/serializer.git", 611 | "reference": "40521cd4908451be804a4ca73717948f4b8c5954" 612 | }, 613 | "dist": { 614 | "type": "zip", 615 | "url": "https://api.github.com/repos/symfony/serializer/zipball/40521cd4908451be804a4ca73717948f4b8c5954", 616 | "reference": "40521cd4908451be804a4ca73717948f4b8c5954", 617 | "shasum": "" 618 | }, 619 | "require": { 620 | "php": "^5.5.9|>=7.0.8" 621 | }, 622 | "conflict": { 623 | "symfony/dependency-injection": "<3.2", 624 | "symfony/property-access": ">=3.0,<3.0.4|>=2.8,<2.8.4", 625 | "symfony/property-info": "<3.1", 626 | "symfony/yaml": "<3.3" 627 | }, 628 | "require-dev": { 629 | "doctrine/annotations": "~1.0", 630 | "doctrine/cache": "~1.0", 631 | "phpdocumentor/reflection-docblock": "^3.0|^4.0", 632 | "symfony/cache": "~3.1", 633 | "symfony/config": "~2.8|~3.0", 634 | "symfony/dependency-injection": "~3.2", 635 | "symfony/http-foundation": "~2.8|~3.0", 636 | "symfony/property-access": "~2.8|~3.0", 637 | "symfony/property-info": "~3.1", 638 | "symfony/yaml": "~3.3" 639 | }, 640 | "suggest": { 641 | "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", 642 | "doctrine/cache": "For using the default cached annotation reader and metadata cache.", 643 | "psr/cache-implementation": "For using the metadata cache.", 644 | "symfony/config": "For using the XML mapping loader.", 645 | "symfony/http-foundation": "To use the DataUriNormalizer.", 646 | "symfony/property-access": "For using the ObjectNormalizer.", 647 | "symfony/property-info": "To deserialize relations.", 648 | "symfony/yaml": "For using the default YAML mapping loader." 649 | }, 650 | "type": "library", 651 | "extra": { 652 | "branch-alias": { 653 | "dev-master": "3.3-dev" 654 | } 655 | }, 656 | "autoload": { 657 | "psr-4": { 658 | "Symfony\\Component\\Serializer\\": "" 659 | }, 660 | "exclude-from-classmap": [ 661 | "/Tests/" 662 | ] 663 | }, 664 | "notification-url": "https://packagist.org/downloads/", 665 | "license": [ 666 | "MIT" 667 | ], 668 | "authors": [ 669 | { 670 | "name": "Fabien Potencier", 671 | "email": "fabien@symfony.com" 672 | }, 673 | { 674 | "name": "Symfony Community", 675 | "homepage": "https://symfony.com/contributors" 676 | } 677 | ], 678 | "description": "Symfony Serializer Component", 679 | "homepage": "https://symfony.com", 680 | "time": "2017-10-02T06:42:24+00:00" 681 | }, 682 | { 683 | "name": "zendframework/zend-servicemanager", 684 | "version": "3.3.0", 685 | "source": { 686 | "type": "git", 687 | "url": "https://github.com/zendframework/zend-servicemanager.git", 688 | "reference": "c3036efb81f71bfa36cc9962ee5d4474f36581d0" 689 | }, 690 | "dist": { 691 | "type": "zip", 692 | "url": "https://api.github.com/repos/zendframework/zend-servicemanager/zipball/c3036efb81f71bfa36cc9962ee5d4474f36581d0", 693 | "reference": "c3036efb81f71bfa36cc9962ee5d4474f36581d0", 694 | "shasum": "" 695 | }, 696 | "require": { 697 | "container-interop/container-interop": "^1.2", 698 | "php": "^5.6 || ^7.0", 699 | "psr/container": "^1.0", 700 | "zendframework/zend-stdlib": "^3.1" 701 | }, 702 | "provide": { 703 | "container-interop/container-interop-implementation": "^1.2", 704 | "psr/container-implementation": "^1.0" 705 | }, 706 | "require-dev": { 707 | "mikey179/vfsstream": "^1.6", 708 | "ocramius/proxy-manager": "^1.0 || ^2.0", 709 | "phpbench/phpbench": "^0.10.0", 710 | "phpunit/phpunit": "^5.7 || ^6.0.6", 711 | "zendframework/zend-coding-standard": "~1.0.0" 712 | }, 713 | "suggest": { 714 | "ocramius/proxy-manager": "ProxyManager 1.* to handle lazy initialization of services", 715 | "zendframework/zend-stdlib": "zend-stdlib ^2.5 if you wish to use the MergeReplaceKey or MergeRemoveKey features in Config instances" 716 | }, 717 | "bin": [ 718 | "bin/generate-deps-for-config-factory", 719 | "bin/generate-factory-for-class" 720 | ], 721 | "type": "library", 722 | "extra": { 723 | "branch-alias": { 724 | "dev-master": "3.3-dev", 725 | "dev-develop": "3.4-dev" 726 | } 727 | }, 728 | "autoload": { 729 | "psr-4": { 730 | "Zend\\ServiceManager\\": "src/" 731 | } 732 | }, 733 | "notification-url": "https://packagist.org/downloads/", 734 | "license": [ 735 | "BSD-3-Clause" 736 | ], 737 | "homepage": "https://github.com/zendframework/zend-servicemanager", 738 | "keywords": [ 739 | "service-manager", 740 | "servicemanager", 741 | "zf" 742 | ], 743 | "time": "2017-03-01T22:08:02+00:00" 744 | }, 745 | { 746 | "name": "zendframework/zend-stdlib", 747 | "version": "3.1.0", 748 | "source": { 749 | "type": "git", 750 | "url": "https://github.com/zendframework/zend-stdlib.git", 751 | "reference": "debedcfc373a293f9250cc9aa03cf121428c8e78" 752 | }, 753 | "dist": { 754 | "type": "zip", 755 | "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/debedcfc373a293f9250cc9aa03cf121428c8e78", 756 | "reference": "debedcfc373a293f9250cc9aa03cf121428c8e78", 757 | "shasum": "" 758 | }, 759 | "require": { 760 | "php": "^5.6 || ^7.0" 761 | }, 762 | "require-dev": { 763 | "athletic/athletic": "~0.1", 764 | "phpunit/phpunit": "~4.0", 765 | "squizlabs/php_codesniffer": "^2.6.2" 766 | }, 767 | "type": "library", 768 | "extra": { 769 | "branch-alias": { 770 | "dev-master": "3.1-dev", 771 | "dev-develop": "3.2-dev" 772 | } 773 | }, 774 | "autoload": { 775 | "psr-4": { 776 | "Zend\\Stdlib\\": "src/" 777 | } 778 | }, 779 | "notification-url": "https://packagist.org/downloads/", 780 | "license": [ 781 | "BSD-3-Clause" 782 | ], 783 | "homepage": "https://github.com/zendframework/zend-stdlib", 784 | "keywords": [ 785 | "stdlib", 786 | "zf2" 787 | ], 788 | "time": "2016-09-13T14:38:50+00:00" 789 | } 790 | ], 791 | "packages-dev": [], 792 | "aliases": [], 793 | "minimum-stability": "dev", 794 | "stability-flags": [], 795 | "prefer-stable": true, 796 | "prefer-lowest": false, 797 | "platform": [], 798 | "platform-dev": [] 799 | } 800 | -------------------------------------------------------------------------------- /container.php: -------------------------------------------------------------------------------- 1 | setFactory( 19 | Mailer::class, 20 | function() { 21 | return new Mailer(); 22 | } 23 | ); 24 | 25 | $container->setFactory( 26 | SendForgotPasswordEmailHandler::class, 27 | function() use ($container) { 28 | return new SendForgotPasswordEmailHandler( 29 | $container->get(Mailer::class) 30 | ); 31 | } 32 | ); 33 | 34 | $container->setFactory( 35 | SendImportantEmailHandler::class, 36 | function() use ($container) { 37 | return new SendImportantEmailHandler( 38 | $container->get(Mailer::class) 39 | ); 40 | } 41 | ); 42 | 43 | return $container; 44 | -------------------------------------------------------------------------------- /queueFactory.php: -------------------------------------------------------------------------------- 1 | 'bernard:', 14 | )); 15 | $driver = new PredisDriver($predis); 16 | 17 | return new PersistentFactory( 18 | $driver, 19 | new Serializer( 20 | new AggregateNormalizer([ 21 | new EnvelopeNormalizer(), 22 | new Symfony\Component\Serializer\Serializer( 23 | [new ObjectNormalizer()], 24 | [new JsonEncoder()] 25 | ), 26 | ]) 27 | 28 | ) 29 | ); 30 | --------------------------------------------------------------------------------