{"id":23380681,"url":"https://github.com/softonic/laravel-protobuf-events","last_synced_at":"2026-02-16T13:33:21.616Z","repository":{"id":43148701,"uuid":"436695523","full_name":"softonic/laravel-protobuf-events","owner":"softonic","description":"Helper to allow nuwber/rabbitevents to work with protobuf","archived":false,"fork":false,"pushed_at":"2026-01-12T17:07:39.000Z","size":49,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-01-12T22:54:43.466Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softonic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-12-09T17:01:38.000Z","updated_at":"2025-02-06T09:54:15.000Z","dependencies_parsed_at":"2025-01-30T16:25:43.109Z","dependency_job_id":"0183069e-c0b7-4d99-ad03-d1c9c4f17e09","html_url":"https://github.com/softonic/laravel-protobuf-events","commit_stats":{"total_commits":18,"total_committers":6,"mean_commits":3.0,"dds":0.7222222222222222,"last_synced_commit":"293264eaf4e52b654806acb3a857ad46f010859d"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/softonic/laravel-protobuf-events","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softonic%2Flaravel-protobuf-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softonic%2Flaravel-protobuf-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softonic%2Flaravel-protobuf-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softonic%2Flaravel-protobuf-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softonic","download_url":"https://codeload.github.com/softonic/laravel-protobuf-events/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softonic%2Flaravel-protobuf-events/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29509139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-12-21T20:17:57.245Z","updated_at":"2026-02-16T13:33:21.610Z","avatar_url":"https://github.com/softonic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Laravel Protobuf Events\n====================\n\n[![Latest Version](https://img.shields.io/github/release/softonic/laravel-protobuf-events.svg?style=flat-square)](https://github.com/softonic/laravel-protobuf-events/releases)\n[![Software License](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/softonic/laravel-protobuf-events/tests.yml?branch=master\u0026style=flat-square)](https://github.com/softonic/laravel-protobuf-events/actions/workflows/tests.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/softonic/laravel-protobuf-events.svg?style=flat-square)](https://packagist.org/packages/softonic/laravel-protobuf-events)\n[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/softonic/laravel-protobuf-events.svg?style=flat-square)](http://isitmaintained.com/project/softonic/laravel-protobuf-events \"Average time to resolve an issue\")\n[![Percentage of issues still open](http://isitmaintained.com/badge/open/softonic/laravel-protobuf-events.svg?style=flat-square)](http://isitmaintained.com/project/softonic/laravel-protobuf-events \"Percentage of issues still open\")\n\nHelper to allow nuwber/rabbitevents to work with protobuf\n\n## Requirements\n\n- PHP \u003e= 8.5\n- Laravel 12.x\n\nMain features\n-------------\n\n* Allow to publish/listen protobuf messages using nuwber/rabbit-events easily.\n\nInstallation\n-------------\n\nYou can require the last version of the package using composer\n```bash\ncomposer require softonic/laravel-protobuf-events\n```\n\n### Configuration\n\nFirst you need to configure the [nuwber/rabbit-events package](https://github.com/nuwber/rabbitevents) to be able\nto use the package.\n\nThen you must configure `config/protobuf-events.php` to set the client of the library. This client allows to isolate\ndifferent services, identifying the origin of the message.\n\n#### Configuring a listener\n\nIn the `RabbitEventsServiceProvider::boot()` register the listeners that you want using the `ExternalEvents::decorateListener()` method.\n```php\n    /**\n     * Register any events for your application.\n     */\n    public function boot(): void\n    {\n        $this-\u003elisten = [\n            'my.routing.key' =\u003e [\n                ExternalEvents::decorateListener(MyListener::class),\n            ],\n        ];\n\n        parent::boot();\n    }\n```\n\nThe listener needs a method called `handle()` that will receive the message and the routing key,\nand a method called `setClient()` to identify the origin of the message.\n```php\nclass MyListener\n{\n    public function setClient(string $client): void\n    {\n        // ...\n    }\n    public function handle(ProtobufExampleMessage $event): void\n    {\n        // ...\n    }\n}\n```\n\n#### Publishing messages\n\nTo publish a message, you need to use the `ExternalEvents::publish()` method.\n```php\nExternalEvents::publish(\n    ':service:',\n    (new ProtobufExampleMessage)\n        -\u003esetName('My name')\n        -\u003esetAge(10)\n);\n```\n\n#### Advanced usage\n\nSometimes you need to use the package in a different way than the default. For example, you can use the package to decode\na message from a string. In that case, you are able to decode the message using the `ExternalEvents::decode()` method.\n\n```php\n$message = ExternalEvents::decode(\n    ProtobufExampleMessage::class,\n    '\\n My name\\n 10\\n' // The message is a string with the protobuf message.\n);\n```\n\n### Logging protobuf messages\n\nIf you want to log the outgoing protobuf messages and the incoming ones, you can configure a logger and a formatter for the message to be logged.\nFor that purpose you have the methods `ExternalEvents::setLogger()` and `ExternalEvents::setFormatter()`.\nThe logger must implement the `Psr\\Log\\LoggerInterface` and the formatter, the `LogMessageFormatterInterface` interface.\n```php\nExternalEvents::setLogger(Log:getFacadeRoot());\nExternalEvents::setFormatter(new ProtobufLogMessageFormatter());\n```\nThe formatter will have two methods, `formatOutgoingMessage()` and `formatIncomingMessage()`, that will be called when a message is sent or received, respectively.\nBoth should return a `LogMessage` object, which contains the message to log and the context.\n\nThe log level can be changed by setting the `communications_log_level` key in `config/protobuf-events.php`.\n\nTesting\n-------\n\n`softonic/laravel-protobuf-events` has a [PHPUnit](https://phpunit.de) test suite, and a coding style compliance test suite using [PHP CS Fixer](http://cs.sensiolabs.org/).\n\nTo run the tests, run the following command from the project folder.\n\n```bash\ndocker compose run --rm test\n```\n\nTo run PHPUnit only:\n\n```bash\ndocker compose run --rm phpunit\n```\n\nTo check code style:\n\n```bash\ndocker compose run --rm php composer run checkstyle\n```\n\nTo fix code style issues:\n\n```bash\ndocker compose run --rm fixcs\n```\n\nTo run static analysis:\n\n```bash\ndocker compose run --rm phpstan\n```\n\nTo open a terminal in the dev environment:\n\n```bash\ndocker compose run --rm php sh\n```\n\nLicense\n-------\n\nThe Apache 2.0 license. Please see [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftonic%2Flaravel-protobuf-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftonic%2Flaravel-protobuf-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftonic%2Flaravel-protobuf-events/lists"}