Skip to content

Commit

Permalink
require google/protobuf (native) (#1067)
Browse files Browse the repository at this point in the history
We made protobuf implementation optional back in #949 however it seems to be tripping up
a number of developers. Since native + extension can be installed at the same time (with
extension taking priority), I think that users will be less surprised when starting out
if there is a working implementation by default.
  • Loading branch information
brettmc authored Jul 4, 2023
1 parent cdb90a7 commit fe37355
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@

## Protobuf Runtime library

OTLP exporting requires a [protobuf runtime library](https://github.com/protocolbuffers/protobuf/tree/main/php).

There exist two protobuf runtime libraries that offer the same set of APIs, allowing developers to choose the one that
best suits their needs.

The first and easiest option is to install the Protobuf PHP Runtime Library through composer. This can be the easiest
way to get started quickly. Either run `composer require google/protobuf`, or update your `composer.json` as follows:

```json
"require": {
"google/protobuf": "^v3.3.0"
}
```
This package requires `google/protobuf`, which is the native implementation. It is easy to install and a good way to get
started quickly.

Alternatively, and the recommended option for production is to install the Protobuf C extension for PHP. The extension
makes both exporters _significantly_ more performant. This can be easily installed with the following command:
```sh
$ sudo pecl install protobuf
makes OTLP exporting _significantly_ more performant. The extension can be installed with the following command:

```shell
pecl install protobuf
```

The extension can be installed alongside the native library, and it will be used instead if available.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
}
],
"require": {
"php": "^7.4 || ^8.0"
"php": "^7.4 || ^8.0",
"google/protobuf": "^3.3.0"
},
"autoload": {
"psr-4": {
Expand All @@ -26,8 +27,7 @@
}
},
"suggest": {
"ext-protobuf": "For better performance, when dealing with the protobuf format",
"google/protobuf": "To get started quickly, install the native protobuf library."
"ext-protobuf": "For better performance, when dealing with the protobuf format"
},
"extra": {
"branch-alias": {
Expand Down

0 comments on commit fe37355

Please sign in to comment.