{"id":13566665,"url":"https://github.com/walkor/rabbitmq","last_synced_at":"2026-01-17T02:01:03.179Z","repository":{"id":38246438,"uuid":"302807161","full_name":"walkor/rabbitmq","owner":"walkor","description":"Asynchronous rabbitmq client for PHP based on workerman.","archived":false,"fork":false,"pushed_at":"2026-01-16T06:56:39.000Z","size":46,"stargazers_count":42,"open_issues_count":5,"forks_count":10,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-01-16T22:03:37.160Z","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/walkor.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-10-10T03:32:48.000Z","updated_at":"2026-01-16T06:56:18.000Z","dependencies_parsed_at":"2024-11-06T04:02:28.479Z","dependency_job_id":"d5b21ced-9ec2-4dff-8228-f1787415f5c9","html_url":"https://github.com/walkor/rabbitmq","commit_stats":{"total_commits":20,"total_committers":6,"mean_commits":"3.3333333333333335","dds":0.7,"last_synced_commit":"4732a2c21f1e9dfd067c88e0123c24a96ab1b1ff"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/walkor/rabbitmq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkor%2Frabbitmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkor%2Frabbitmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkor%2Frabbitmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkor%2Frabbitmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/walkor","download_url":"https://codeload.github.com/walkor/rabbitmq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkor%2Frabbitmq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28492047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"online","status_checked_at":"2026-01-17T02:00:07.808Z","response_time":85,"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":[],"created_at":"2024-08-01T13:02:14.205Z","updated_at":"2026-01-17T02:01:03.099Z","avatar_url":"https://github.com/walkor.png","language":"PHP","readme":"# Rabbitmq\nAsynchronous rabbitmq client for PHP based on [workerman](https://github.com/walkor/workerman).\n\n# Install\n```\ncomposer require workerman/rabbitmq\n```\n\n# Examples\n\n## Consumer\n\n- receive.php\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Bunny\\Channel;\nuse Bunny\\Message;\nuse Workerman\\Worker;\nuse Workerman\\RabbitMQ\\Client;\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$worker = new Worker();\n$worker-\u003eeventLoop = \\Workerman\\Events\\Fiber::class;\n\n$worker-\u003eonWorkerStart = function() {\n    // Create RabbitMQ Client\n    $client = Client::factory([\n        'host' =\u003e '127.0.0.1',\n        'port' =\u003e 5672,\n        'user' =\u003e 'guest',\n        'password' =\u003e 'guest',\n        'vhost' =\u003e '/',\n        'heartbeat' =\u003e 60,\n        'heartbeat_callback' =\u003e function () {\n            echo \" [-] coroutine-consumer-heartbeat\\n\";\n        },\n        'interval' =\u003e [100, 300]\n    ])-\u003econnect();\n    $channel = $client-\u003echannel();\n    $channel-\u003equeueDeclare('hello-coroutine');\n\n    // Consumer\n    $channel-\u003econsume(function (Message $message, Channel $channel, \\Bunny\\AbstractClient $client) {\n        echo \" [\u003e] Received \", $message-\u003econtent, \"\\n\";\n    },\n        'hello-coroutine',\n        '',\n        false,\n        true\n    );\n    $client-\u003erun();\n    echo ' [*] Waiting for messages. To exit press CTRL+C', \"\\n\";\n\n    // Producer\n    \\Workerman\\Timer::add($interval = 5 , function () use ($channel) {\n        $channel-\u003epublish($message = 'Hello World By Self Timer. ' . time(), [], '', 'hello-coroutine');\n        echo \" [\u003c] Sent $message\\n\";\n    });\n    echo \" [!] Producer timer created, interval: $interval s.\\n\";\n\n};\nWorker::runAll();\n```\n- Run command `php receive.php start`.\n\n## Publish use on Workerman ENV\n\n- send.php\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Workerman\\RabbitMQ\\Client;\nuse Workerman\\Worker;\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$worker = new Worker();\n$worker-\u003eeventLoop = \\Workerman\\Events\\Fiber::class;\n\n$worker-\u003eonWorkerStart = function() {\n    $client = Client::factory([\n        'host' =\u003e 'host.docker.internal',\n        'port' =\u003e 5672,\n        'user' =\u003e 'guest',\n        'password' =\u003e 'guest',\n        'vhost' =\u003e '/',\n        'heartbeat' =\u003e 60,\n        'heartbeat_callback' =\u003e function () {\n            echo \"coroutine-producer-heartbeat\\n\";\n        }\n    ])-\u003econnect();\n    $channel = $client-\u003echannel();\n    $channel-\u003equeueDeclare('hello-coroutine');\n\n    // 每5秒发一个消息\n    \\Workerman\\Timer::add(5, function () use ($channel) {\n        $channel-\u003epublish($message = 'Hello World By Workerman Env Producer. ' . time(), [], '', 'hello-coroutine');\n        echo \" [x] Sent '$message'\\n\";\n    });\n};\nWorker::runAll();\n```\n- Run command `php send.php start`.\n\n## Publish script or use on PHP-FPM\n\n- script.php\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Workerman\\RabbitMQ\\Client;\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$client = Client::factory([\n    'host' =\u003e 'host.docker.internal',\n    'port' =\u003e 5672,\n    'user' =\u003e 'guest',\n    'password' =\u003e 'guest',\n    'vhost' =\u003e '/',\n    'heartbeat' =\u003e 60,\n    'heartbeat_callback' =\u003e function () {\n        echo \"coroutine-producer-heartbeat\\n\";\n    }\n])-\u003econnect();\n$channel = $client-\u003echannel();\n$channel-\u003equeueDeclare('hello-coroutine');\n$res = $channel-\u003epublish($message = 'Hello World By Normal Producer. ' . time(), [], '', 'hello-coroutine');\n\necho \" [x] Sent '$message', success: $res\\n\";\n\n```\n- Run command `php script.php`.\n\n## Async Consumer\n\n- receive.php\n```php\n\u003c?php\n\nuse Bunny\\Channel;\nuse Bunny\\Message;\nuse Workerman\\Worker;\nuse Workerman\\RabbitMQ\\Client;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$worker = new Worker();\n\n$worker-\u003eonWorkerStart = function() {\n    (new Client())-\u003econnect()-\u003ethen(function (Client $client) {\n        return $client-\u003echannel();\n    })-\u003ethen(function (Channel $channel) {\n        return $channel-\u003equeueDeclare('hello', false, false, false, false)-\u003ethen(function () use ($channel) {\n            return $channel;\n        });\n    })-\u003ethen(function (Channel $channel) {\n        echo ' [*] Waiting for messages. To exit press CTRL+C', \"\\n\";\n        $channel-\u003econsume(\n            function (Message $message, Channel $channel, Client $client) {\n                echo \" [x] Received \", $message-\u003econtent, \"\\n\";\n            },\n            'hello',\n            '',\n            false,\n            true\n        );\n    });\n};\nWorker::runAll();\n```\n- Run command `php receive.php start`.\n\n## Async Producer\n\n- send.php\n```php\n\u003c?php\nuse Bunny\\Channel;\nuse Bunny\\Message;\nuse Workerman\\Worker;\nuse Workerman\\RabbitMQ\\Client;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$worker = new Worker();\n\n$worker-\u003eonWorkerStart = function() {\n    (new Client())-\u003econnect()-\u003ethen(function (Client $client) {\n        return $client-\u003echannel();\n    })-\u003ethen(function (Channel $channel) {\n        return $channel-\u003equeueDeclare('hello', false, false, false, false)-\u003ethen(function () use ($channel) {\n            return $channel;\n        });\n    })-\u003ethen(function (Channel $channel) {\n        echo \" [x] Sending 'Hello World!'\\n\";\n        return $channel-\u003epublish('Hello World!', [], '', 'hello')-\u003ethen(function () use ($channel) {\n            return $channel;\n        });\n    })-\u003ethen(function (Channel $channel) {\n        echo \" [x] Sent 'Hello World!'\\n\";\n        $client = $channel-\u003egetClient();\n        return $channel-\u003eclose()-\u003ethen(function () use ($client) {\n            return $client;\n        });\n    })-\u003ethen(function (Client $client) {\n        $client-\u003edisconnect();\n    });\n};\nWorker::runAll();\n```\n- Run command `php send.php start`.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkor%2Frabbitmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalkor%2Frabbitmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkor%2Frabbitmq/lists"}