{"id":29440018,"url":"https://github.com/rxcod9/laravel-grpc-example","last_synced_at":"2026-05-16T13:05:04.370Z","repository":{"id":304406612,"uuid":"1018213395","full_name":"rxcod9/laravel-grpc-example","owner":"rxcod9","description":"This repository demonstrates a minimal yet production-ready gRPC integration using Laravel with RoadRunner and Spiral PHP gRPC. It contains two Laravel Sail applications:","archived":false,"fork":false,"pushed_at":"2026-03-31T08:48:23.000Z","size":115,"stargazers_count":0,"open_issues_count":11,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-31T10:28:13.527Z","etag":null,"topics":["demo","grpc","laravel"],"latest_commit_sha":null,"homepage":"","language":"Blade","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/rxcod9.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-11T20:07:02.000Z","updated_at":"2025-10-18T11:03:00.000Z","dependencies_parsed_at":"2025-07-12T23:26:04.186Z","dependency_job_id":"2a4d4fbf-7986-405c-9c24-c59d4c35fbbc","html_url":"https://github.com/rxcod9/laravel-grpc-example","commit_stats":null,"previous_names":["rxcod9/laravel-grpc-example"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rxcod9/laravel-grpc-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxcod9%2Flaravel-grpc-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxcod9%2Flaravel-grpc-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxcod9%2Flaravel-grpc-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxcod9%2Flaravel-grpc-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxcod9","download_url":"https://codeload.github.com/rxcod9/laravel-grpc-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxcod9%2Flaravel-grpc-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33103971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["demo","grpc","laravel"],"created_at":"2025-07-13T10:01:53.554Z","updated_at":"2026-05-16T13:05:04.347Z","avatar_url":"https://github.com/rxcod9.png","language":"Blade","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel gRPC Example (Publisher ↔ Consumer)\n\nThis repository demonstrates a **minimal yet production-ready gRPC integration** using **Laravel** with **RoadRunner** and **Spiral PHP gRPC**. It contains two Laravel Sail applications:\n\n- `publisher-app`: Publishes gRPC messages\n- `consumer-app`: Listens and processes gRPC messages\n\nBoth services communicate via `gRPC` using **Protocol Buffers**.\n\n---\n\n## 🧱 Architecture\n\n```\n[publisher-app] Laravel → Spiral\\GRPC\\Client\n    |\n    |   gRPC over TCP (default port 50051)\n    v\n[consumer-app] Laravel + RoadRunner gRPC server\n```\n\n- Laravel Sail (Docker-based)\n- `spiral/roadrunner` for gRPC server\n- `namely/protoc-all` for generating PHP stubs\n- No PECL compilation; all `.so` files prebuilt and compressed\n- Protos are **local per service**, not shared\n\n---\n\n## ⚙️ Prerequisites\n\n- PHP 8.4+ (via Sail)\n- Docker + Docker Compose\n- Composer\n- Laravel Sail\n- ✅ No need for local `grpc.so` / `protobuf.so` or PECL tools\n\n---\n\n## 🚀 Quick Setup\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/rxcod9/laravel-grpc-example.git\ncd laravel-grpc-example\n```\n\n### 2. Install PHP and Composer Dependencies\n\n#### Installing directly:\n\n```sh\ncd publisher-app \u0026\u0026 composer install\ncd consumer-app \u0026\u0026 composer install\n```\n\n#### Or Installing Composer Dependencies through `docker`:\n\nIf you do not have php8.4 in host and wants to use docker with php8.4 for installing composer.\n```sh\ncd publisher-app\ndocker run --rm \\\n        --pull=always \\\n        -v \"$(pwd)\":/opt \\\n        -w /opt \\\n        laravelsail/php84-composer:latest \\\n        bash -c \"composer install\"\n\ncd consumer-app\ndocker run --rm \\\n        --pull=always \\\n        -v \"$(pwd)\":/opt \\\n        -w /opt \\\n        laravelsail/php84-composer:latest \\\n        bash -c \"composer install\"\n```\n\n### 3. Generate PHP gRPC Stubs\n\nWhen you add.modify .proto files, you need to generate these files\n\n#### Using `protoc` directly:\n\n```sh\n# For publisher-app\ncd publisher-app/\nprotoc --proto_path=./protos \\\n  --plugin=protoc-gen-php=$(which protoc-gen-php) \\\n  --plugin=protoc-gen-php-grpc=/usr/local/bin/protoc-gen-php-grpc \\\n  --php_out=./app/Grpc \\\n  --php-grpc_out=./app/Grpc \\\n  ./protos/messages.proto\n\n# For consumer-app\ncd consumer-app/\nprotoc --proto_path=./protos \\\n  --plugin=protoc-gen-php=$(which protoc-gen-php) \\\n  --plugin=protoc-gen-php-grpc=/usr/local/bin/protoc-gen-php-grpc \\\n  --php_out=./app/Grpc \\\n  --php-grpc_out=./app/Grpc \\\n  ./protos/messages.proto\n```\n\n#### Or using Docker:\n\n```sh\ncd publisher-app/\ndocker run --rm \\\n    -v \"$PWD:/workspace\" \\\n    -w /workspace namely/protoc-all \\\n    -f protos/messages.proto \\\n    -l php \\\n    -o app/Grpc\n\ncd consumer-app/\ndocker run --rm \\\n    -v \"$PWD:/workspace\" \\\n    -w /workspace namely/protoc-all \\\n    -f protos/messages.proto \\\n    -l php \\\n    -o app/Grpc\n```\n\n\u003e This uses `namely/protoc-all` to avoid installing Protobuf toolchains locally.\n\n\n### 4. Start the Applications with Sail\n\n```sh\ncd publisher-app\n./vendor/bin/sail up -d\ncd consumer-app\n./vendor/bin/sail up -d\n```\n\n---\n\n## 🐘 Prebuilt PHP Extensions\n\nThe `.so` files for `grpc` and `protobuf` are:\n\n- Precompiled\n- Compressed into `grpc-protobuf.tar.gz`\n- Extracted into `/usr/lib/php/20240924` inside the Sail containers\n- Auto-enabled in `/etc/php/8.3/cli/conf.d/99-grpc.ini`\n\nThis avoids long PECL install times and keeps builds deterministic.\n\n---\n\n## 📦 Artisan Command: Send Message\n\nYou can test the gRPC publisher:\n\n```bash\ncd publisher-app\n./vendor/bin/sail artisan grpc:publish-message notifications '{\"event\":\"user.registered\"}'\n```\n\nExpected output:\n\n```json\n{\n  \"success\": true,\n  \"message\": \"Message sent to consumer via gRPC\"\n}\n```\n\n---\n\n## 🧪 Debugging \u0026 Logs\n\nTo tail consumer logs:\n\n```bash\ncd consumer-app\n./vendor/bin/sail logs -f\n```\n\nVerify gRPC extension is loaded:\n\n```bash\n./vendor/bin/sail php -m | grep grpc\n./vendor/bin/sail php -m | grep protobuf\n```\n\n---\n\n## 🛑 Stopping Services\n\n```bash\ncd publisher-app \u0026\u0026 ./vendor/bin/sail down\ncd consumer-app \u0026\u0026 ./vendor/bin/sail down\n```\n\n---\n\n## 📂 Project Structure\n\n```bash\nlaravel-grpc-example/\n├── consumer-app/        # Laravel gRPC server with RoadRunner + Supervisor\n│   ├── app/Grpc/        # Generated gRPC stub code\n│   ├── protos/          # Local proto definitions\n│   └── start-container  # Entrypoint\n└── publisher-app/       # Laravel gRPC client\n    ├── app/Grpc/        # Generated gRPC stub code\n    ├── protos/          # Local proto definitions\n    └── grpc:publish-message command\n```\n\n---\n\n## 🌍 Environment Configuration\n\nMake sure these `.env` variables are set:\n\n**consumer-app/.env**\n```env\nGRPC_PORT=50051\n```\n\n**publisher-app/.env**\n```env\nCONSUMER_PORT=50051\n```\n\n---\n\n## 🛠 RoadRunner gRPC Server Setup (consumer-app)\n\n1. RoadRunner runs via Supervisor\n2. On container start:\n   - `bootstrap.php` is invoked\n   - Registers `MessageService`\n   - Logs to stdout\n\n---\n\n## 📈 Future Improvements\n\n- Use `.proto` sync between services (e.g., via `@shared-protos` git submodule)\n- Add TLS support (gRPC + secure channels)\n- Use GitHub Actions to generate `.so` into GitHub Releases\n- Implement streaming/bidirectional gRPC calls\n- Integrate with Laravel Events/Queue workers\n\n---\n\n## 🧠 Got Questions?\n\nFeel free to open an [issue](https://github.com/rxcod9/laravel-grpc-example/issues) or discuss ideas for enhancements. Contributions are welcome!\n\n---\n\n## 📜 License\n\nMIT — free to use, modify, and distribute.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxcod9%2Flaravel-grpc-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxcod9%2Flaravel-grpc-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxcod9%2Flaravel-grpc-example/lists"}