• Stars
    star
    114
  • Rank 300,925 (Top 7 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 5 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use php-fpm as a simple built-in async queue

PHP-FPM Async Queue

Use php-fpm as a simple built-in async queue. Based on interoperable queue interfaces Queue Interop.

Usage

composer makasim/php-fpm-queue:0.1.x-dev queue-interop/queue-interop:0.7.x-dev enqueue/dsn:0.9.x-dev

A sender script:

<?php
# sender.php

use Makasim\PhpFpm\PhpFpmConnectionFactory;

require_once __DIR__.'/vendor/autoload.php';

$context = (new PhpFpmConnectionFactory('tcp://localhost:9000'))->createContext();

$queue = $context->createQueue('/app/worker.php');
$message = $context->createMessage('aBody');

$context->createProducer()->send($queue, $message);

A worker script:

<?php
# worker.php

use Makasim\PhpFpm\PhpFpmConnectionFactory;

require_once __DIR__.'/vendor/autoload.php';

$context = (new PhpFpmConnectionFactory('tcp://localhost:9000'))->createContext();
// or
//$context = (new PhpFpmConnectionFactory('unix:///var/run/php/php7.1-fpm.sock'))->createContext(); 

$queue = $context->createQueue(__FILE__);

$consumer = $context->createConsumer($queue);

if ($message = $consumer->receiveNoWait()) {
    // process message

    $consumer->acknowledge($message);
}

Start PHP-FPM:

docker run -v `pwd`:/app -p 9000:9000 php:7.2-fpm

Send a message:

php sender.php

Credits

Inspired by Benjamin post Using php-fpm as a simple built-in async queue

License

MIT License

More Repositories

1

amqpextra

Golang AMQP reliable connection, publisher, consumer.
Go
73
star
2

docker-nginx-php-fpm-supervisor

The alternative solution to https://github.com/makasim/docker-nginx-php-fpm where supervisord is used.
Smarty
52
star
3

sentryhook

Sentry hook for Logrus
Go
43
star
4

PayumBundleSandbox

Symfony2 application to play with PayumBundle.
PHP
34
star
5

TempFile

PHP
29
star
6

sfPhpunitPlugin

Integrate phpunit framework with symfony one
PHP
24
star
7

fpErrorNotifierPlugin

A symfony plugin that add ability to catch all kind of exceptions\errors including fatal ones and send them as a mail.
PHP
16
star
8

docker-nginx-php-fpm

Smarty
9
star
9

rabbitmq-cli-consumer-client

Queue Interop based client for rabbitmq-cli-consumer.
PHP
6
star
10

sfPhpunitNetbeansPlugin

Easy run phpunit tests in NetBeans IDE
PHP
6
star
11

doctrine-tester

A doctrine integration test helper
PHP
3
star
12

ymltoerl

Converts YAML to Erlang config.
Go
2
star
13

batcher

Compose concurrent single items into batches on the fly.
Go
2
star
14

buildinfo

Embed some meta about your Golang application.
Go
2
star
15

go-app-template

It's my approach to structure go files. A basic template.
Go
2
star
16

datadiff

Stores data diffs and allows to review them at nice simple page.
JavaScript
2
star
17

Domain_Model

It is a way to work with models. You define API then make a method chain and in one query fetch all data you need.
PHP
2
star
18

amqpbench

A tool for generating some rate-limited traffic to RabbitMQ queue.
Go
2
star
19

PayumModuleSandbox

A sandbox for playing with payum module for zf2
PHP
2
star
20

JRM

It's an ORM for converting PHP data to Javascript and back.
JavaScript
1
star
21

fpBackupPlugin

Make backuping of mysql db easy.
PHP
1
star
22

go-prophet

Golang wrapper for Facebook's Prophet - Forecasting at scale library.
Go
1
star
23

httprouter

Golang HTTP Router
Go
1
star
24

fastjsonrpc

Fast JSON RPC 1.0 codec for net\rpc server.
Go
1
star
25

sfPhpunitHelperPlugin

The plugin adds helpers for selenium functional tests. It makes easy to test mails sent to gmail, admin generated pages
PHP
1
star
26

fpFilePlugin

Set of filesystem abstration integrated with symfony framework.
PHP
1
star
27

dbmateincode

Could run dbmate migrations embedded in binary via fs.FS
Go
1
star
28

yadm-benchmark

The code I used to do benchmarks.
PHP
1
star
29

fpExecPlugin

PHP
1
star
30

Domain_Model_TestApp

The test application for Domain_Model lib. You can look at it to find out how does the lib work.
PHP
1
star
31

symfony-message-component

POC
PHP
1
star
32

amqprpc

Go protocol agnostic RPC Client over AMQP.
Go
1
star
33

PHP_MQ

ActiveMQ client for PHP
PHP
1
star
34

php-direct

Php Direct Server
PHP
1
star
35

backpressure

Go
1
star
36

rada-gov-ua-parser

Parser of Ukrainian's Rada laws.
PHP
1
star