• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 6 years ago
  • Updated over 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
72
star
2

docker-nginx-php-fpm-supervisor

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

sentryhook

Sentry hook for Logrus
Go
42
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

flowstate

Flowstate machine.
Go
5
star
12

batcher

Compose concurrent single items into batches on the fly.
Go
3
star
13

doctrine-tester

A doctrine integration test helper
PHP
3
star
14

ymltoerl

Converts YAML to Erlang config.
Go
2
star
15

go-prophet

Golang wrapper for Facebook's Prophet - Forecasting at scale library.
Go
2
star
16

buildinfo

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

httprouter

Golang HTTP Router
Go
2
star
18

go-app-template

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

datadiff

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

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
21

PayumModuleSandbox

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

amqpbench

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

JRM

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

fastjsonrpc

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

fpBackupPlugin

Make backuping of mysql db easy.
PHP
1
star
26

sfPhpunitHelperPlugin

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

fpFilePlugin

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

dbmateincode

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

yadm-benchmark

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

fpExecPlugin

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

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
35

php-direct

Php Direct Server
PHP
1
star
36

backpressure

Go
1
star
37

rada-gov-ua-parser

Parser of Ukrainian's Rada laws.
PHP
1
star