PHPackages                             mariopenterman/protobuf-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mariopenterman/protobuf-plugin

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mariopenterman/protobuf-plugin
==============================

PHP Code generator plugin from Google's Protocol Buffers

0.1.4(4y ago)05MITPHPPHP &gt;=5.5.0

Since Feb 17Pushed 4y agoCompare

[ Source](https://github.com/mariopenterman/protobuf-plugin)[ Packagist](https://packagist.org/packages/mariopenterman/protobuf-plugin)[ Docs](https://github.com/mariopenterman/protobuf-plugin)[ RSS](/packages/mariopenterman-protobuf-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (15)Versions (8)Used By (0)

Protobuf for PHP
================

[](#protobuf-for-php)

[![Build Status](https://camo.githubusercontent.com/3d21be5355c89b9f58d60a66b664a2bc62dd5304b6869a73a7bbef0f56397eb3/68747470733a2f2f7472617669732d63692e6f72672f70726f746f6275662d7068702f70726f746f6275662d706c7567696e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/protobuf-php/protobuf-plugin)[![Coverage Status](https://camo.githubusercontent.com/f4017d42c465a8c07db62626d38c5d32c691fb46f8ad48203633845226ef507b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f70726f746f6275662d7068702f70726f746f6275662d706c7567696e2f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/protobuf-php/protobuf-plugin?branch=master)

Protobuf for PHP is an implementation of Google's Protocol Buffers for the PHP language, supporting its binary data serialization and including a `protoc`plugin to generate PHP classes from `.proto` files.

Installation
------------

[](#installation)

If you wish to compile `.proto` definitions to PHP, you will need to install [Google's Protocol Buffers](https://github.com/google/protobuf) from your favorite package manager or from source. This plugin currently supports protobuf 2.3.0. or later.

**Note**: *Google's Protocol Buffers and `proto` is not a runtime requirement for [protobuf-php/protobuf](https://github.com/protobuf-php/protobuf), It is only necessary if you wish to compile your definitions to PHP using [protobuf-php/protobuf-plugin](https://github.com/protobuf-php/protobuf-plugin).*

#### Installing Google's Protocol Buffers

[](#installing-googles-protocol-buffers)

- **OSX Install**

```
$ brew install protobuf
```

- **Ubuntu**

```
$ sudo apt-get install -y protobuf
```

Make sure you have `protoc` available in the user's path:

```
$ protoc --version
$ # libprotoc 2.6.1
```

**Note**: *For more information on how to install/compile Google's Protocol Buffers see : *

#### Composer install

[](#composer-install)

To install the PHP plugin run the following `composer` commands:

```
$ composer require "protobuf-php/protobuf-plugin"
```

#### Defining Your Protocol Format

[](#defining-your-protocol-format)

To create your address book application, you'll need to start with a `.proto` file. The definitions in a `.proto` file are simple: you add a message for each data structure you want to serialize, then specify a name and a type for each field in the message. Here is the `.proto` file that defines your messages, `addressbook.proto`.

```
package tutorial;
import "php.proto";
option (php.package) = "Tutorial.AddressBookProtos";

message Person {
  required string name = 1;
  required int32 id = 2;
  optional string email = 3;

  enum PhoneType {
    MOBILE = 0;
    HOME = 1;
    WORK = 2;
  }

  message PhoneNumber {
    required string number = 1;
    optional PhoneType type = 2 [default = HOME];
  }

  repeated PhoneNumber phone = 4;
}

message AddressBook {
  repeated Person person = 1;
}
```

As you can see, the syntax is similar to C++ or Java. Let's go through each part of the file and see what it does. The `.proto` file starts with a package declaration, which helps to prevent naming conflicts between different projects. In PHP, the package name is used as the PHP namespace unless you have explicitly specified a `(php.package)`, as we have here. Even if you do provide a `(php.package)`, you should still define a normal package as well to avoid name collisions in the Protocol Buffers name space as well as in non PHP languages.

You'll find a complete guide to writing `.proto` files – including all the possible field types – in the [Protocol Buffer Language Guide](https://developers.google.com/protocol-buffers/docs/proto). Don't go looking for facilities similar to class inheritance, though – protocol buffers don't do that.

#### Compiling Your Protocol Buffers

[](#compiling-your-protocol-buffers)

Now that you have a `.proto`, the next thing you need to do is generate the classes you'll need to read and write `AddressBook` (and hence `Person` and `PhoneNumber`) messages. To do this, you need to run the protocol buffer plugin on your `.proto`.

In this case:

```
php ./vendor/bin/protobuf --include-descriptors -i . -o ./src/ ./addressbook.proto
```

This generates the following PHP classes in your specified destination directory

```
src/
└── Tutorial
    └── AddressBookProtos
        ├── AddressBook.php
        ├── Person
        │   ├── PhoneNumber.php
        │   └── PhoneType.php
        └── Person.php
```

**Note**: *For more information on how to use the generated code see : [protobuf-php/protobuf](https://github.com/protobuf-php/protobuf)*

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~329 days

Recently: every ~451 days

Total

7

Last Release

1758d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/475f1f8d42ddc99b869b7d68384698a0942475361b6bef88d6bbf7a995c5e38c?d=identicon)[mariopenterman](/maintainers/mariopenterman)

---

Top Contributors

[![FabioBatSilva](https://avatars.githubusercontent.com/u/588172?v=4)](https://github.com/FabioBatSilva "FabioBatSilva (73 commits)")[![mariopenterman](https://avatars.githubusercontent.com/u/7958909?v=4)](https://github.com/mariopenterman "mariopenterman (1 commits)")[![rodrigodiez](https://avatars.githubusercontent.com/u/823685?v=4)](https://github.com/rodrigodiez "rodrigodiez (1 commits)")[![skydiablo](https://avatars.githubusercontent.com/u/956423?v=4)](https://github.com/skydiablo "skydiablo (1 commits)")

---

Tags

protobufprotocol bufferserializing

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mariopenterman-protobuf-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/mariopenterman-protobuf-plugin/health.svg)](https://phpackages.com/packages/mariopenterman-protobuf-plugin)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M16.9k](/packages/laravel-framework)[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M560](/packages/symfony-maker-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M646](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[protobuf-php/protobuf-plugin

PHP Code generator plugin from Google's Protocol Buffers

57141.6k17](/packages/protobuf-php-protobuf-plugin)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
