Weave 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

Pbj Laravel Package

gdbots/pbj

gdbots/pbj brings Protocol Buffers to PHP with schema-driven message classes, built-in validation, and serialization to JSON, binary, and protobuf. Define a schema once, generate PHP classes, and move data reliably between services with a consistent, type-safe format.

View on GitHub
Deep Wiki
Context7

gdbots/pbj is a PHP library for defining and working with schema-driven messages. It provides a protobuf-inspired model for typed fields, defaults, validation, and consistent serialization, making it useful for APIs, event-driven systems, and services that need shared message contracts.

  • Schema-first message definitions with typed fields and defaults
  • Built-in validation for message integrity
  • JSON and binary serialization for transport and storage
  • Extensible field types and custom serialization support
  • Composer-ready PHP integration
Frequently asked questions about Pbj
What is gdbots/pbj and how does it work with Laravel?
gdbots/pbj is a PHP implementation of Protocol Buffers-style message tools for schema-driven message classes, binary and JSON serialization, enums, and structured data exchange. It is a framework-agnostic Composer package, so you can use it inside Laravel services, jobs, controllers, and console commands without a Laravel-specific wrapper. Basic usage involves defining or generating message classes and then instantiating and serializing them in your application code.
How do I install gdbots/pbj in a Laravel project?
Install the package with Composer using composer require gdbots/pbj. Because it is not described as a Laravel-specific package, you generally do not need to register a service provider just to use its message and serialization classes. You can instantiate message objects directly or resolve them through Laravel's container if your application has custom bindings.
Does gdbots/pbj support binary and JSON serialization?
Yes. The package provides binary and JSON serialization for its schema-driven message classes, which makes it useful for APIs, queues, storage, and service-to-service communication. You can serialize messages to either format and deserialize them back into message objects. This lets Laravel applications exchange structured data in a compact binary form or a readable JSON form.
Can I use gdbots/pbj to define message schemas and enums in Laravel?
Yes. gdbots/pbj is built around schema-driven message classes and includes support for enums, so you can model structured data with controlled field values. In a Laravel application, those generated or defined message classes can be used in domain services, API resources, queue payloads, and validation-adjacent workflows. You should follow the package's schema and code-generation conventions from its documentation.
Which Laravel and PHP versions are supported by gdbots/pbj?
The package is a framework-agnostic PHP library, so Laravel compatibility depends mainly on the PHP version required by the package and your Laravel installation. Check the composer.json constraints for gdbots/pbj and its dependencies before installing it in a specific Laravel release. For the most accurate support matrix, compare those constraints with your application's PHP and Laravel versions.
How does gdbots/pbj compare to Google Protobuf for PHP?
gdbots/pbj is described as Protobuf-inspired message tooling for PHP and JSON, with schema-driven message classes, enums, and binary plus JSON serialization. The official google/protobuf PHP package is the reference implementation for Protocol Buffers and is the safer choice when strict wire-format interoperability with other Protobuf toolchains is required. If you only need Protobuf-style structured messages within PHP services, gdbots/pbj may be a lighter, PHP-native option to evaluate.
Is gdbots/pbj suitable for production use in a Laravel application?
gdbots/pbj can be used in production Laravel applications, but you should evaluate its release stability, test coverage, and maintenance activity before adopting it. Pin a known-good Composer version and include serialization round-trip tests for the message types your application depends on. Also review how schema changes will be rolled out so producers and consumers remain compatible.
How do I test messages and serialization with gdbots/pbj?
Write PHPUnit tests that instantiate your message classes, populate fields and enums, serialize to binary and JSON, then deserialize and assert the expected values. You can run these tests in Laravel's test suite or in plain PHPUnit, depending on how your project is set up. Focus on round-trip tests, required-field behavior, enum handling, and compatibility with any stored or queued payloads.
Do I need to configure gdbots/pbj in Laravel?
The package is primarily used through its message classes and serialization APIs rather than a Laravel configuration file. If your application needs custom bindings or shared message factories, you can register them in a Laravel service provider. Otherwise, follow the package README for schema definition, class generation, and serialization usage.
What are alternatives to gdbots/pbj for structured data in Laravel?
Alternatives include the official google/protobuf PHP package, Symfony Serializer, spatie/laravel-data, JSON Schema validators, and plain PHP DTOs with custom serialization. Choose based on whether you need strict Protobuf interoperability, Laravel-friendly DTO features, JSON readability, or minimal dependencies. gdbots/pbj is most relevant when you want Protobuf-inspired schema-driven messages with binary and JSON serialization in PHP.
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.
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route