{"id":21273478,"url":"https://github.com/graphaware/php-simplemq","last_synced_at":"2025-06-13T08:06:03.253Z","repository":{"id":62512335,"uuid":"39349188","full_name":"graphaware/php-simplemq","owner":"graphaware","description":"RabbitMQ's Rapid Application Development based on YAML definition","archived":false,"fork":false,"pushed_at":"2016-01-07T04:43:12.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-06-13T08:05:59.077Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphaware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-19T21:13:14.000Z","updated_at":"2016-03-14T10:55:09.000Z","dependencies_parsed_at":"2022-11-02T12:48:36.275Z","dependency_job_id":null,"html_url":"https://github.com/graphaware/php-simplemq","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/graphaware/php-simplemq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fphp-simplemq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fphp-simplemq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fphp-simplemq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fphp-simplemq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphaware","download_url":"https://codeload.github.com/graphaware/php-simplemq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fphp-simplemq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259606867,"owners_count":22883556,"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","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":[],"created_at":"2024-11-21T09:14:57.230Z","updated_at":"2025-06-13T08:06:03.209Z","avatar_url":"https://github.com/graphaware.png","language":"PHP","readme":"### GraphAware's PHP Simple Message Queue for RabbitMQ\n\nRabbitMQ's Rapid Application Development.\n\nThis library makes possible to create channels, queues, bindings, producers, consumers, .. on the fly by only providing \na simple YAML configuration file.\n\n[![Build Status](https://travis-ci.org/graphaware/php-simplemq.svg?branch=master)](https://travis-ci.org/graphaware/php-simplemq)\n\n### Usage\n\nRequire the library dependency :\n\n```bash\ncomposer require graphaware/php-simplemq\n```\n\nDefine the connections, exchanges, producers and consumers, eg:\n\n```yaml\nsimple_mq:\n  connections:\n    default:\n      host: 192.168.59.103\n      port: 5672\n      user: admin\n      password: error\n      vhost: \"/\"\n\n  exchanges:\n    logs:\n      connection: default\n      type: fanout\n      durable: true\n\n    error-logs:\n      connection: default\n      type: direct\n      durable: true\n\n  producers:\n    logs:\n      exchange: logs\n\n    errors:\n      exchange: error-logs\n      routing_key: error\n\n  consumers:\n    logs-printer:\n      exchange: logs\n      ack: true\n      queue:\n        name: my-app-all-logs\n        durable: true\n        qos:\n          prefetch_count: 1\n\n    error-logs-recorder:\n      exchange: error-logs\n      queue:\n        name: my-app-error-logs\n        durable: true\n        qos:\n          prefetch_size: 1\n        bindings:\n          -\n            queue: my-app-error-logs\n            routing_key: error\n```\n\nBootstrap the library by providing your configuration file location :\n\n```php\n\nrequire_once(__DIR__.'/vendor/autoload.php');\n\nuse GraphAware\\SimpleMQ\\SimpleMQ;\n\n$smq = SimpleMQ::withYAMLConfigFile(__DIR__.'/path_to_your_config_file.yml');\n```\n\nBased on the example configuration, producers named `logs` and `errors` as well as consumers named `logs-printer` and \n`error-logs-recorder` are available through the library.\n\nTo retrieve and start consuming queues, you can get the consumer with the following method :\n\n```php\n$consumer = $smq-\u003egetConsumer('logs-printer');\n\n$callback = function($message) {\n    print_r($message-\u003ebody);\n};\n\n$consumer-\u003econsume($callback);\n```\n\nGetting a single message :\n\n```php\n$message = $consumer-\u003egetMessage();\n// Returns a AMQPMessage instance\n```\n\nGetting more than one message :\n\n```php\n$messages = $consumer-\u003egetMessageBatch(10);\n// Returns an array of AMQPMessage\n```\n\nSometimes, there can be a latency between a message is sent and this message to be seen by the producers (for eg in CI suites).\n\nYou can define a maxAttempts to reach the batchSize before stopping reading queues :\n\n```php\n$messages = $consumer-\u003egetMessageBatch(10, 20);\n```\n\nAnd to start sending messages to exchanges, it is pretty much the same :\n\n```php\n$producer = $smq-\u003egetProducer('errors');\n$message = json_encode(array('id' =\u003e 1234, 'text' =\u003e 'Hello world'));\n\n$producer-\u003esendMessage($message);\n```\n\nThe producer and consumers knows exactly, based on the configuration, which routing key to use for direct and topic exchanges and\nalso which binding keys to use for binding queues to exchanges.\n\n\n--- \n\nLicense: MIT\n\nAuthor: [Christophe Willemsen](mailto:christophe@graphaware.com)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphaware%2Fphp-simplemq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphaware%2Fphp-simplemq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphaware%2Fphp-simplemq/lists"}