### Setup development environment Source: https://php-enqueue.github.io/contribution Commands to install dependencies and initialize the development environment. ```bash composer install ./bin/pre-commit -i ./bin/dev -b ``` -------------------------------- ### Run Magento Setup Upgrade Source: https://php-enqueue.github.io/magento2/quick_tour Execute this command to ensure Magento2 recognizes the newly installed module. ```bash php bin/magento setup:upgrade ``` -------------------------------- ### Install enqueue/null via Composer Source: https://php-enqueue.github.io/transport/null Use Composer to install the enqueue/null package. This is the required setup step before using the NULL transport. ```bash $ composer require enqueue/null ``` -------------------------------- ### Install Thruway and start WAMP router Source: https://php-enqueue.github.io/transport/wamp Install the Thruway library and start the SimpleWsRouter example to run a WAMP router on 127.0.0.1 port 9090. ```bash $ composer require voryx/thruway $ php vendor/voryx/thruway/Examples/SimpleWsRouter.php ``` -------------------------------- ### Install with php-redis extension Source: https://php-enqueue.github.io/transport/redis Install the required system extension and the Enqueue Redis package. ```bash $ apt-get install php-redis $ composer require enqueue/redis ``` -------------------------------- ### Install enqueue/laravel-queue and transport Source: https://php-enqueue.github.io/laravel/quick_tour Install the required packages using Composer. ```bash $ composer require enqueue/laravel-queue enqueue/fs ``` -------------------------------- ### Install with predis library Source: https://php-enqueue.github.io/transport/redis Install the Enqueue Redis package and the predis library. ```bash $ composer require enqueue/redis predis/predis:^1 ``` -------------------------------- ### Install EnqueueBundle via Composer Source: https://php-enqueue.github.io/bundle/quick_tour Install the bundle and the filesystem transport using Composer. ```bash $ composer require enqueue/enqueue-bundle enqueue/fs ``` -------------------------------- ### Install enqueue/amqp-lib via Composer Source: https://php-enqueue.github.io/transport/amqp_lib Install the enqueue/amqp-lib package using Composer. ```bash $ composer require enqueue/amqp-lib ``` -------------------------------- ### Install Enqueue simple client and AMQP extension Source: https://php-enqueue.github.io/client/quick_tour Composer command to install the enqueue/simple-client and enqueue/amqp-ext packages. ```bash $ composer require enqueue/simple-client enqueue/amqp-ext ``` -------------------------------- ### Install enqueue/simple-client Source: https://php-enqueue.github.io/laravel/quick_tour Install the simple client library to use the Enqueue Simple Client in your Laravel application. ```bash $ composer require enqueue/simple-client ``` -------------------------------- ### Install Enqueue DBAL Source: https://php-enqueue.github.io/transport/dbal Install the required package via Composer. ```bash $ composer require enqueue/dbal ``` -------------------------------- ### Install enqueue/gps package Source: https://php-enqueue.github.io/transport/gps Install the Google Cloud Pub/Sub transport library using Composer. ```shell $ composer require enqueue/gps ``` -------------------------------- ### Install async dispatcher and transport Source: https://php-enqueue.github.io/async_event_dispatcher/quick_tour Use Composer to install the required async dispatcher library and a supported transport, such as the filesystem transport. ```bash $ composer require enqueue/async-event-dispatcher enqueue/fs ``` -------------------------------- ### Run documentation locally with Docker Source: https://php-enqueue.github.io/ Execute this command from the repository root directory to start a Jekyll server for the documentation. The site will be accessible at http://localhost:4000/. ```bash docker run -p 4000:4000 --rm --volume="${PWD}/docs:/srv/jekyll" -it jekyll/jekyll jekyll serve --watch ``` -------------------------------- ### Install Enqueue Filesystem package Source: https://php-enqueue.github.io/transport/filesystem Use Composer to install the required package for filesystem transport. ```bash $ composer require enqueue/fs ``` -------------------------------- ### Install Enqueue SNS-SQS Source: https://php-enqueue.github.io/transport/snsqs Install the required package via Composer. ```bash $ composer require enqueue/snsqs ``` -------------------------------- ### Install enqueue/dsn with Composer Source: https://php-enqueue.github.io/dsn Install the enqueue/dsn package version 0.9.x using Composer. ```bash composer req enqueue/dsn 0.9.x ``` -------------------------------- ### Install Enqueue SQS Source: https://php-enqueue.github.io/transport/sqs Use Composer to install the Enqueue SQS package. ```bash $ composer require enqueue/sqs ``` -------------------------------- ### Install enqueue/wamp via Composer Source: https://php-enqueue.github.io/transport/wamp Install the enqueue/wamp package using Composer. ```bash $ composer require enqueue/wamp ``` -------------------------------- ### Install Enqueue Module via Composer Source: https://php-enqueue.github.io/magento2/quick_tour Run these commands in the application root directory to install the necessary libraries. ```bash composer require "enqueue/magento2-enqueue:*@dev" "enqueue/amqp-ext" ``` -------------------------------- ### Install Enqueue Monitoring via Composer Source: https://php-enqueue.github.io/monitoring Use this command to install the Enqueue monitoring package. ```bash composer req enqueue/monitoring:0.9.x-dev ``` -------------------------------- ### Configure AMQP Interop Connection Source: https://php-enqueue.github.io/laravel/queues Example configuration for an AMQP connection using the interop driver. ```php env('QUEUE_DRIVER', 'interop'), 'connections' => [ 'interop' => [ 'driver' => 'interop', // connects to localhost 'dsn' => 'amqp:', // // could be "rabbitmq_dlx", "rabbitmq_delay_plugin", instance of DelayStrategy interface or null // 'delay_strategy' => 'rabbitmq_dlx' ], ], ]; ``` -------------------------------- ### Install async-command via Composer Source: https://php-enqueue.github.io/bundle/async_commands Use this command to install the async-command package in your project. ```bash $ composer require enqueue/async-command:0.9.x-dev ``` -------------------------------- ### Install Kafka transport Source: https://php-enqueue.github.io/transport/kafka Use composer to install the required rdkafka package. ```bash $ composer require enqueue/rdkafka ``` -------------------------------- ### Install AMQP Bunny transport Source: https://php-enqueue.github.io/transport/amqp_bunny Use Composer to install the enqueue/amqp-bunny package. ```bash $ composer require enqueue/amqp-bunny ``` -------------------------------- ### Install enqueue/stomp via Composer Source: https://php-enqueue.github.io/transport/stomp Use Composer to install the enqueue/stomp package. ```bash $ composer require enqueue/stomp ``` -------------------------------- ### Install Magento Enqueue via Composer Source: https://php-enqueue.github.io/magento/quick_tour Run these commands in the application root directory to install the necessary composer plugin and the Enqueue library. ```bash composer require "magento-hackathon/magento-composer-installer:~3.0" composer require "enqueue/magento-enqueue:*@dev" "enqueue/amqp-ext" ``` -------------------------------- ### Install AMQP transport via Composer Source: https://php-enqueue.github.io/transport/amqp Use Composer to install the enqueue/amqp-ext package. Ensure the AMQP extension version is at least 1.9.3. ```bash $ composer require enqueue/amqp-ext ``` -------------------------------- ### Consume messages via CLI with setup-broker Source: https://php-enqueue.github.io/client/quick_tour Command to consume messages using the enqueue:consume command with verbose output and automatic broker setup. ```bash $ php bin/enqueue.php enqueue:consume -vvv --setup-broker ``` -------------------------------- ### Run consume command from console Source: https://php-enqueue.github.io/quick_tour Starts the consumption process by running the app.php script with the 'consume' command. ```bash $ app.php consume ``` -------------------------------- ### Install Enqueue Monolog Handler dependencies Source: https://php-enqueue.github.io/monolog/send-messages-to-mq Install the required packages including monolog, the queue interop handler, and the filesystem transport via composer. ```bash composer require enqueue/monolog-queue-handler monolog/monolog enqueue/fs ``` -------------------------------- ### enqueue:transport:consume command help Source: https://php-enqueue.github.io/bundle/cli_commands Displays the help information and available options for the enqueue:transport:consume command, which is used to start a worker that consumes messages from a broker. ```bash ./bin/console enqueue:transport:consume --help Usage: enqueue:transport:consume [options] [--] []... Arguments: processor A message processor. queues A queue to consume from Options: --message-limit=MESSAGE-LIMIT Consume n messages and exit --time-limit=TIME-LIMIT Consume messages during this time --memory-limit=MEMORY-LIMIT Consume messages until process reaches this memory limit in MB --niceness=NICENESS Set process niceness --receive-timeout=RECEIVE-TIMEOUT The time in milliseconds queue consumer waits for a message. --logger[=LOGGER] A logger to be used. Could be "default", "null", "stdout". [default: "default"] -t, --transport[=TRANSPORT] The transport to consume messages from. [default: "default"] -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -e, --env=ENV The Environment name. [default: "test"] --no-debug Switches off debug mode. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: A worker that consumes message from a broker. To use this broker you have to explicitly set a queue to consume from and a message processor service ``` -------------------------------- ### Consume messages with bindTopic and consume Source: https://php-enqueue.github.io/client/quick_tour Shows how to bind a topic to a callback that processes messages and returns Processor::ACK, then start consuming. ```php bindTopic('a_bar_topic', function(Message $psrMessage) { // processing logic here return Processor::ACK; }); $client->consume(); ``` -------------------------------- ### enqueue:setup-broker command help Source: https://php-enqueue.github.io/bundle/cli_commands Displays the help information for the enqueue:setup-broker command, which configures the broker by creating queues and topics. ```bash ./bin/console enqueue:setup-broker --help Usage: enqueue:setup-broker [options] enq:sb Options: -c, --client[=CLIENT] The client to consume messages from. [default: "default"] -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -e, --env=ENV The Environment name. [default: "test"] --no-debug Switches off debug mode. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: Setup broker. Configure the broker, creates queues, topics and so on. ``` -------------------------------- ### Configure Symfony bundle Source: https://php-enqueue.github.io/transport/kafka Provides examples for configuring the Enqueue transport in Symfony, including basic DSN setup and extended configuration with custom Kafka options. ```yaml # app/config/config.yml enqueue: default: transport: "rdkafka:" client: ~ ``` ```yaml # app/config/config.yml enqueue: default: transport: dsn: "rdkafka://" global: ### Make sure this is unique for each application / consumer group and does not change ### Otherwise, Kafka won't be able to track your last offset and will always start according to ### `auto.offset.reset` setting. ### See Kafka documentation regarding `group.id` property if you want to know more group.id: 'foo-app' metadata.broker.list: 'example.com:1000' topic: auto.offset.reset: beginning ### Commit async is true by default since version 0.9.9. ### It is suggested to set it to true in earlier versions since otherwise consumers become extremely slow, ### waiting for offset to be stored on Kafka before continuing. commit_async: true client: ~ ``` -------------------------------- ### Install Gearman transport Source: https://php-enqueue.github.io/transport/gearman Use composer to install the required package. ```bash $ composer require enqueue/gearman ``` -------------------------------- ### Configure async event dispatcher Source: https://php-enqueue.github.io/async_event_dispatcher/quick_tour Set up the connection, registry, and async listener in config.php to prepare the event dispatcher for asynchronous operations. ```php createContext(); $eventQueue = $context->createQueue('symfony_events'); $registry = new SimpleRegistry( ['the_event' => 'default'], ['default' => new PhpSerializerEventTransformer($context)] ); $asyncListener = new AsyncListener($context, $registry, $eventQueue); $dispatcher = new EventDispatcher(); // the listener sends even as a message through MQ $dispatcher->addListener('the_event', $asyncListener); $asyncDispatcher = new AsyncEventDispatcher($dispatcher, $asyncListener); // the listener is executed on consumer side. $asyncDispatcher->addListener('the_event', function() { }); $asyncProcessor = new AsyncProcessor($registry, $asyncDispatcher); ``` -------------------------------- ### Send and consume command messages with SimpleClient and reply support Source: https://php-enqueue.github.io/quick_tour Binds command handlers, sets up the broker, sends commands, and optionally receives replies. Shows how to send a command with reply expectation and consume with ReplyExtension. Includes commented composer require lines for amqp-ext, amqp-bunny, amqp-lib, and fs. ```php bindCommand('bar_command', function(Message $message) { // your bar command processor logic here }); $client->bindCommand('baz_reply_command', function(Message $message, Context $context) { // your baz reply command processor logic here return Result::reply($context->createMessage('theReplyBody')); }); $client->setupBroker(); // It is sent to one consumer. $client->sendCommand('bar_command', 'aMessageData'); // It is possible to get reply $promise = $client->sendCommand('bar_command', 'aMessageData', true); // you can send several commands and only after start getting replies. $replyMessage = $promise->receive(2000); // 2 sec // this is a blocking call, it'll consume message until it is interrupted $client->consume([new ReplyExtension()]); ``` -------------------------------- ### Create AMQP context Source: https://php-enqueue.github.io/transport/amqp Demonstrates various ways to initialize the AmqpConnectionFactory, including default settings, DSN strings, and SSL configurations. ```php 'example.com', 'port' => 1000, 'vhost' => '/', 'user' => 'user', 'pass' => 'pass', 'persisted' => false, ]); // same as above but given as DSN string $factory = new AmqpConnectionFactory('amqp://user:pass@example.com:10000/%2f'); // SSL or secure connection $factory = new AmqpConnectionFactory([ 'dsn' => 'amqps:', 'ssl_cacert' => '/path/to/cacert.pem', 'ssl_cert' => '/path/to/cert.pem', 'ssl_key' => '/path/to/key.pem', ]); $context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN $context = (new \Enqueue\ConnectionFactoryFactory())->create('amqp:')->createContext(); $context = (new \Enqueue\ConnectionFactoryFactory())->create('amqp+ext:')->createContext(); ``` -------------------------------- ### Install Enqueue MongoDB transport Source: https://php-enqueue.github.io/transport/mongodb Use Composer to install the MongoDB transport package. ```bash $ composer require enqueue/mongodb ``` -------------------------------- ### Configure config/enqueue.php Source: https://php-enqueue.github.io/laravel/quick_tour Create the configuration file to define the transport and client settings. ```php [ 'transport' => [ 'default' => 'file://'.realpath(__DIR__.'/../storage/enqueue') ], 'client' => [ 'router_topic' => 'default', 'router_queue' => 'default', 'default_queue' => 'default', ], ], ]; ``` -------------------------------- ### Install Pheanstalk transport Source: https://php-enqueue.github.io/transport/pheanstalk Use Composer to install the required package for the Pheanstalk transport. ```bash $ composer require enqueue/pheanstalk ``` -------------------------------- ### Create AMQP context Source: https://php-enqueue.github.io/transport/amqp_bunny Demonstrates various ways to initialize the AmqpConnectionFactory and create a context, including local connections, custom configurations, and DSN strings. ```php 'example.com', 'port' => 1000, 'vhost' => '/', 'user' => 'user', 'pass' => 'pass', 'persisted' => false, ]); // same as above but given as DSN string $factory = new AmqpConnectionFactory('amqp://user:pass@example.com:10000/%2f'); $context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN $context = (new \Enqueue\ConnectionFactoryFactory())->create('amqp:')->createContext(); $context = (new \Enqueue\ConnectionFactoryFactory())->create('amqp+bunny:')->createContext(); ``` -------------------------------- ### Configure SimpleClient with AMQP transport Source: https://php-enqueue.github.io/client/quick_tour PHP code showing how to instantiate SimpleClient with the 'amqp:' DSN. Requires the Composer autoloader. ```php 'example.com', 'port' => 1000, 'login' => 'theLogin', ]); // same as above but given as DSN string $factory = new StompConnectionFactory('stomp://example.com:1000?login=theLogin'); $context = $factory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN $context = (new \Enqueue\ConnectionFactoryFactory())->create('stomp:')->createContext(); ``` -------------------------------- ### Create RdKafkaConnectionFactory context Source: https://php-enqueue.github.io/transport/kafka Demonstrates various ways to initialize the RdKafkaConnectionFactory, including connecting to localhost, using DSN strings, and passing custom global or topic configuration options. ```php [ 'group.id' => uniqid('', true), 'metadata.broker.list' => 'example.com:1000', 'enable.auto.commit' => 'false', ], 'topic' => [ 'auto.offset.reset' => 'beginning', ], ]); $context = $connectionFactory->createContext(); // if you have enqueue/enqueue library installed you can use a factory to build context from DSN $context = (new \Enqueue\ConnectionFactoryFactory())->create('kafka:')->createContext(); ``` -------------------------------- ### Install WAMP transport packages Source: https://php-enqueue.github.io/monitoring Install the required Thruway packages via Composer to enable WAMP storage. ```bash composer req thruway/pawl-transport:^0.5.0 thruway/client:^0.5.0 ``` -------------------------------- ### Declare and bind topics and queues Source: https://php-enqueue.github.io/transport/snsqs Create topics and queues on the broker and bind them to enable message routing. ```php createTopic('in'); $context->declareTopic($inTopic); $out1Queue = $context->createQueue('out1'); $context->declareQueue($out1Queue); $out2Queue = $context->createQueue('out2'); $context->declareQueue($out2Queue); $context->bind($inTopic, $out1Queue); $context->bind($inTopic, $out2Queue); // to remove topic/queue use deleteTopic/deleteQueue method //$context->deleteTopic($inTopic); //$context->deleteQueue($out1Queue); //$context->unbind(inTopic, $out1Queue); ``` -------------------------------- ### Create CLI application with Enqueue commands Source: https://php-enqueue.github.io/client/quick_tour PHP script (bin/enqueue.php) that sets up a Symfony Console application with commands for setup-broker, routes, produce, and consume. ```php #!/usr/bin/env php add(new SimpleSetupBrokerCommand($client->getDriver())); $application->add(new SimpleRoutesCommand($client->getDriver())); $application->add(new SimpleProduceCommand($client->getProducer())); $application->add(new SimpleConsumeCommand( $client->getQueueConsumer(), $client->getDriver(), $client->getDelegateProcessor() )); $application->run(); ``` -------------------------------- ### Example Controller Action for Profiling Source: https://php-enqueue.github.io/bundle/debugging An example controller action demonstrating how to use the producer to send events, which can then be inspected in the Symfony profiler. ```php get('enqueue.producer'); $producer->sendEvent('foo_topic', 'Hello world'); $producer->sendEvent('bar_topic', ['bar' => 'val']); $message = new Message(); $message->setBody('baz'); $producer->sendEvent('baz_topic', $message); // ... } ``` -------------------------------- ### enqueue:routes command help Source: https://php-enqueue.github.io/bundle/cli_commands Displays the help information and available options for the enqueue:routes command, which lists all registered routes. ```bash ./bin/console enqueue:routes --help Usage: enqueue:routes [options] debug:enqueue:routes Options: --show-route-options Adds ability to hide options. -c, --client[=CLIENT] The client to consume messages from. [default: "default"] -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -e, --env=ENV The Environment name. [default: "test"] --no-debug Switches off debug mode. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: A command lists all registered routes. ``` -------------------------------- ### Create context with predis and custom options Source: https://php-enqueue.github.io/transport/redis Initialize the Redis context with custom predis options for advanced control. ```php 'localhost', 'port' => 6379, 'predis_options' => [ 'prefix' => 'ns:' ] ]; $redis = new PRedis($config); $factory = new RedisConnectionFactory($redis); ``` -------------------------------- ### Broken pipe or closed connection error Source: https://php-enqueue.github.io/transport/amqp_lib Example of the exception thrown when the connection is lost. ```text PHP Fatal error: Uncaught exception 'PhpAmqpLib\Exception\AMQPRuntimeException' with message 'Broken pipe or closed connection' in /some/path/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php:190 ``` -------------------------------- ### Run Queue Listener Source: https://php-enqueue.github.io/yii/amqp_driver Command to start the daemon process that listens for and executes queued tasks. ```bash yii queue/listen ``` -------------------------------- ### Display help for enqueue:consume Source: https://php-enqueue.github.io/bundle/cli_commands Displays the usage, arguments, and options for the enqueue:consume command. ```bash ./bin/console enqueue:consume --help Usage: enqueue:consume [options] [--] []... enq:c Arguments: client-queue-names Queues to consume messages from Options: --message-limit=MESSAGE-LIMIT Consume n messages and exit --time-limit=TIME-LIMIT Consume messages during this time --memory-limit=MEMORY-LIMIT Consume messages until process reaches this memory limit in MB --niceness=NICENESS Set process niceness --setup-broker Creates queues, topics, exchanges, binding etc on broker side. --receive-timeout=RECEIVE-TIMEOUT The time in milliseconds queue consumer waits for a message. --logger[=LOGGER] A logger to be used. Could be "default", "null", "stdout". [default: "default"] --skip[=SKIP] Queues to skip consumption of messages from (multiple values allowed) -c, --client[=CLIENT] The client to consume messages from. [default: "default"] -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -e, --env=ENV The Environment name. [default: "test"] --no-debug Switches off debug mode. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: A client's worker that processes messages. By default it connects to default queue. It select an appropriate message processor based on a message headers ``` -------------------------------- ### Run Message Consume Command Source: https://php-enqueue.github.io/magento/quick_tour Execute the shell script to start consuming messages from the broker. ```bash $ php shell/enqueue.php enqueue:consume -vvv --setup-broker ``` -------------------------------- ### enqueue:produce command help Source: https://php-enqueue.github.io/bundle/cli_commands Displays the help information for the enqueue:produce command, which is used to send an event to a topic. ```bash ./bin/console enqueue:produce --help Usage: enqueue:produce [options] [--] Arguments: message A message Options: -c, --client[=CLIENT] The client to send messages to. [default: "default"] --topic[=TOPIC] The topic to send a message to --command[=COMMAND] The command to send a message to -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -e, --env=ENV The Environment name. [default: "test"] --no-debug Switches off debug mode. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Help: Sends an event to the topic ```