-
Notifications
You must be signed in to change notification settings - Fork 15.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding provide to php composer.json #13141
Conversation
Adding composer config to allow the native protobuf extension to provide ext-protobuf. This allows libraries to require at least one protobuf implementation. If the extension is not available, it can be provided by the native package. If the extension is available but the native package is required, the native will be installed. Importantly, for libraries which require at least one of them to be installed, composer will complain if neither is available.
My testing: {
"repositories": [
{
"type": "vcs",
"url": "https://github.com/brettmc/protobuf-php"
}
],
"require": {
"ext-protobuf": "*"
}
} No extension: $ php --ri protobuf
Extension 'protobuf' not present.
$ composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires PHP extension ext-protobuf * but it is missing from your system. Install or enable PHP's protobuf extension.
### install forked branch with provide:
$ composer require google/protobuf dev-provides
./composer.json has been updated
Running composer update google/protobuf
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking google/protobuf (dev-provides 18e3096)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing google/protobuf (dev-provides 18e3096): Extracting archive
1 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
No security vulnerability advisories found
$ composer check-platform-reqs
Checking platform requirements for packages in the vendor dir
ext-protobuf * success provided by google/protobuf
php 8.0.27 success Extension installed: $ php --ri protobuf
protobuf
Version => 3.21.6
$ composer update
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
No installed packages - skipping audit.
$ composer check-platform-reqs
No vendor dir present, checking platform requirements from the lock file
ext-protobuf 3.21.6 success Extension installed, require native anyway: $ php --ri protobuf
protobuf
Version => 3.21.6
$ composer require google/protobuf dev-provides
./composer.json has been updated
Running composer update google/protobuf
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking google/protobuf (dev-provides 18e3096)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing google/protobuf (dev-provides 18e3096): Extracting archive
1 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
No security vulnerability advisories found
$ composer check-platform-reqs
Checking platform requirements for packages in the vendor dir
ext-protobuf * success provided by google/protobuf
php 8.0.27 success |
@fowles - I don't think running the tests was supposed to close the PR. I couldn't see in any of the jobs why that might have happened. |
@brettmc marking it "safe for tests" caused GHA to run, when those were green, copybara brought it inside google where a changelist was created in piper, that was then code reviewed internally, and submitted. Copybara then merged that submission externally as d603b41. For reasons I do not understand, sometimes copybara can do this by merging a PR and sometimes it generates an identical commit in github but does not merge it. In this case, it did the latter. You should still see your change in our git repo properly creditted to you. |
Adding composer config to allow the native protobuf extension to provide ext-protobuf.
This allows libraries to require at least one protobuf implementation. If the extension is not available, it can be provided by the native package. If the extension is available but the native package is required, the native will be installed.
Importantly, for libraries which require at least one of them to be installed, composer will complain if neither is available.