Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Protobuf Php

Protobuf Php Laravel Package

centraldesktop/protobuf-php

PHP implementation of Google Protocol Buffers with a protoc plugin to generate type-hinted PHP classes from .proto files. Supports binary serialization, multiple codecs (JSON/XML/etc), services, extensions, reflection, and dynamic messages with lazy decoding.

View on GitHub
Deep Wiki
Context7

PHP implementation of Google's Protocol Buffers with a protoc plugin compiler

Frequently asked questions about Protobuf Php
How do I install and set up **protobuf-php** in a Laravel project?
Run `composer require centraldesktop/protobuf-php` to install the package. You’ll also need Google’s `protoc` compiler (v2.3+) and PEAR’s `Console_CommandLine`. For Laravel, ensure PHP 7.4+ is used (PHP 5.3 is deprecated). Use the `protoc` plugin to generate PHP classes from your `.proto` files.
Can I use this package to replace JSON/XML serialization in Laravel APIs?
Yes. The package supports multiple codecs (binary, JSON, XML, etc.), so you can serialize/deserialize Eloquent models or API responses efficiently. For APIs, use the binary codec for smaller payloads and faster parsing, or JSON for compatibility with clients.
Does **protobuf-php** support Laravel’s Eloquent models or database storage?
You can serialize Eloquent models to binary (e.g., for Redis or database blobs), but there’s no built-in migration tool for `.proto` schema changes. Manually sync schema updates and validate data before storage to avoid corruption.
What Laravel versions and PHP versions does this package support?
The package officially supports PHP 5.3+, but Laravel 8+ requires PHP 7.4+. Upgrade to PHP 7.4+ for modern Laravel versions. Test integer/float handling if migrating from older PHP, as precision quirks may require validation layers.
How do I handle large protobuf messages in Laravel (e.g., >10MB)?
The package loads entire messages into memory, which may cause issues with large payloads. Benchmark your use case and consider chunking data or streaming alternatives (e.g., gRPC for PHP). For now, avoid payloads exceeding ~10MB without optimization.
Can I generate PHP classes from `.proto` files without running `protoc`?
No, the `protoc` compiler is required to generate PHP classes. However, the package supports dynamic messages via reflection, so you can work with protobuf data without code generation for simple use cases.
What are the alternatives to **protobuf-php** for Laravel?
Consider `php-protobuf` (active, PHP 8+ support, better streaming) or `MessagePack` (simpler, lighter, but less feature-rich). For JSON-focused apps, stick with Laravel’s built-in serialization, but protobuf offers superior performance for binary data.
How do I customize the generated PHP classes from `.proto` files?
The package uses template-based code generation, so you can override templates to customize generated classes. Check the [README](https://github.com/centraldesktop/Protobuf-PHP) for details on extending or modifying the output.
Does this package support gRPC or streaming RPC in Laravel?
No, this package focuses on protobuf serialization and message generation, not gRPC. For streaming RPC, consider integrating with a gRPC library like `php-grpc` or using binary protobuf over HTTP with custom middleware.
How do I validate protobuf data in Laravel (e.g., from untrusted sources)?
Use Laravel’s validation rules or custom logic to check protobuf data before processing. The package supports reflection, so you can inspect dynamic messages for required fields or value ranges. For critical data, combine with schema validation tools.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky