{"id":19419532,"url":"https://github.com/eexit/php-mq-sdk","last_synced_at":"2025-08-31T14:04:47.815Z","repository":{"id":136624995,"uuid":"98557097","full_name":"eexit/php-mq-sdk","owner":"eexit","description":"Amazon SQS or AMQP message queue production and consumption for PHP","archived":false,"fork":false,"pushed_at":"2017-07-27T17:28:20.000Z","size":30,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-18T09:09:54.412Z","etag":null,"topics":["amazon-sqs","amqp","message-queue","messaging-library","mq","php","rabbitmq","rabbitmq-client","sqs"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eexit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-27T16:13:38.000Z","updated_at":"2019-08-22T02:30:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"b5ad7e1b-2a6e-4a2a-a866-f7b79e1c2275","html_url":"https://github.com/eexit/php-mq-sdk","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/eexit/php-mq-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eexit%2Fphp-mq-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eexit%2Fphp-mq-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eexit%2Fphp-mq-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eexit%2Fphp-mq-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eexit","download_url":"https://codeload.github.com/eexit/php-mq-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eexit%2Fphp-mq-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272988919,"owners_count":25026961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon-sqs","amqp","message-queue","messaging-library","mq","php","rabbitmq","rabbitmq-client","sqs"],"created_at":"2024-11-10T13:18:08.604Z","updated_at":"2025-08-31T14:04:47.797Z","avatar_url":"https://github.com/eexit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Message Queue SDK [![Build Status](https://travis-ci.org/eexit/php-mq-sdk.svg?branch=master)](https://travis-ci.org/eexit/php-mq-sdk)\n\nThis PHP SDK aims for easy integration of message queues in various developments such as microservices.\nThe use of this SDK allows only the publishing and fetching for messages, you cannot create, delete, purge queue or any other action.\n\n### Available adapters\n\n - [Amazon SQS](http://aws.amazon.com/sqs/) v.2\n - [AMQP](https://github.com/php-amqplib/php-amqplib) v.0.9.1\n\n#### Adapter constraints\n\n##### SQS\n\n - Batch sending, receiving and deletion not supported\n - Message attribute binary type not supported\n\n##### AMQP\n\n - Publishing to exchange not supported\n\nSee the [CHANGE LOG](CHANGELOG.md) for version release information.\n\n## Installation\n\nThen run the command:\n\n    $ composer require eexit/php-mq-sdk:~1.0\n\n## Usage\n\nSee the `examples` directory content.\n\n### Logging\n\nExample with a [PSR-3](http://www.php-fig.org/psr/psr-3/) logger such as [Monolog](https://github.com/Seldaek/monolog):\n\n```php\n\u003c?php\nuse Monolog\\Logger;\nuse Monolog\\Handler\\StreamHandler;\n\n$handler = new StreamHandler(__DIR__ . '/sandbox.log', Logger::INFO);\n$logger = new Logger('Sandbox');\n$logger-\u003epushHandler($handler);\n\n/** \\Eexit\\Mq\\MessageQueue $mq */\n$mq-\u003esetLogger($logger);\n```\n\nExample of log with the `INFO` level:\n\n```\n[2015-07-08 13:33:57] Sandbox.INFO: Open a connection [] []\n[2015-07-08 13:33:59] Sandbox.INFO: Published message abb12d0a-97c3-4dcd-a45f-8be097bbe6bf in 1.6550381183624 ms [] []\n[2015-07-08 13:33:59] Sandbox.INFO: Start listening to on incoming messages [] []\n[2015-07-08 13:33:59] Sandbox.INFO: Fetched message 5c13c13e-86e5-4100-8e50-5168a0bd9608 in 0.15714406967163 ms [] []\n[2015-07-08 13:33:59] Sandbox.INFO: Acked message 5c13c13e-86e5-4100-8e50-5168a0bd9608 in 0.13068604469299 ms [] []\n[2015-07-08 13:33:59] Sandbox.INFO: Close the connection [] []\n```\n\nIf you use the `DEBUG` level, you'll get way more information such as the message content and error stack traces.\n\n### Unix signal handling\n\nThe SDK supports Unix signal handling (via [PCNTL extension](http://php.net/manual/en/book.pcntl.php)) in order to gracefully shutdown your processes:\n\n```php\n\u003c?php\n// MQ signal handler:\n$signalHandler = function ($signal) {\n    switch ($signal) {\n        case SIGINT:\n        case SIGQUIT:\n        case SIGTERM:\n            $this-\u003emq-\u003estop();\n            \\pcntl_signal($signal, SIG_DFL); // Restores original signal handler\n            break;\n    }\n};\n\n// If the extension is loaded, registers the signal handlers\nif (extension_loaded('pcntl')) {\n    \\pcntl_signal(SIGINT, $signalHandler);\n    \\pcntl_signal(SIGQUIT, $signalHandler);\n    \\pcntl_signal(SIGTERM, $signalHandler);\n}\n\n/*\n  MQ bootstrap...\n*/\n\n$mq-\u003elisten($queue, function(EnvelopeInterface $message, MessageQueue $mq) {\n    // The process can be stop from inside\n    return $mq-\u003estop();\n\n    throw new WillNeverBeThrown();\n});\n\n// Closes the connections/gathers log \u0026 metrics accordingly!\n$mq-\u003eclose();\n```\n\nThere is [a working example](examples/amqp/worker.php) of signal handling for AMQP.\n\n### Metric collection\n\nThis library use the [Collector interface](https://github.com/beberlei/metrics/blob/master/src/Beberlei/Metrics/Collector/Collector.php) of [beberlei/metrics](https://github.com/beberlei/metrics) library. This allows you to use any of the supported metric backends.\n\nHere's an example with StatsD:\n\n```php\n\u003c?php\nuse Eexit\\Mq\\Adapter\\Sqs\\Sqs;\nuse Beberlei\\Metrics\\Collector\\StatsD;\n\n$collector = new StatsD(/* backend host */);\n\n// Adds the collector and a prefix to avoid metric naming conflicts\n// You can use the adapter prefix if you want\n/** \\Eexit\\Mq\\MessageQueue $mq */\n$mq-\u003esetMetricCollector($collector, Sqs::METRIC_PREFIX);\n\n// In your worker business code you can add other metrics\n// Note: the metric prefix is only used internally. You may use you own prefix here\n$mq-\u003egetMetricCollector()-\u003eincrement('my_app.my_metric.succeed');\n```\n\n#### Internal metrics\n\n| **Description**                   | **Metric name**                     |\n|--------------------------------   |----------------------------------   |\n| Connection open success count     | `{prefix}.connection.open.succeed`  |\n| Connection open duration          | `{prefix}.connection.open_time`     |\n| Connection open failure count     | `{prefix}.connection.open.failed`   |\n| Connection stop success count     | `{prefix}.connection.stop.succeed`  |\n| Connection stop duration          | `{prefix}.connection.stop_time`     |\n| Connection stop failure count     | `{prefix}.connection.stop.failed`   |\n| Connection close success count    | `{prefix}.connection.close.succeed` |\n| Connection close duration         | `{prefix}.connection.close_time`    |\n| Connection close failure count    | `{prefix}.connection.close.failed`  |\n| Message publication success count | `{prefix}.message.publish.succeed`  |\n| Message publication duration      | `{prefix}.message.publish_time`     |\n| Message publication failure count | `{prefix}.message.publish.failed`   |\n| Message fetch success count       | `{prefix}.message.fetch.succeed`    |\n| Message fetch duration            | `{prefix}.message.fetch_time`       |\n| Message listen failure count      | `{prefix}.message.listen.failed`    |\n| Message ack success count         | `{prefix}.message.ack.succeed`      |\n| Message ack duration              | `{prefix}.message.ack_time`         |\n| Message ack failure count         | `{prefix}.message.ack.failed`       |\n| Message nack success count        | `{prefix}.message.nack.succeed`     |\n| Message nack duration             | `{prefix}.message.nack_time`        |\n| Message nack failure count        | `{prefix}.message.nack.failed`      |\n| Message processing duration       | `{prefix}.message.process_time`     |\n\nFor example, if you use the SQS adapter and use the `Sqs::METRIC_PREFIX` prefix, your metrics will look like this:\n\n    mq.sqs.connection.open_time\n    mq.sqs.message.publish.succeed\n    mq.sqs.message.publish_time\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feexit%2Fphp-mq-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feexit%2Fphp-mq-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feexit%2Fphp-mq-sdk/lists"}