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.
Closes#13141
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13141 from brettmc:php-provides-ext 72d3e447f3
PiperOrigin-RevId: 546312826
If you are running an older version of PHP, you can install a previous release
of the protobuf PHP extension by running pecl install protobuf-3.23.3.
PiperOrigin-RevId: 546056449
* Some more updates to PHP testing infrastructure (#8576)
* WIP.
* Added build config for all of the tests.
* Use ../src/protoc if it is available, for cases where Bazel isn't available.
* Added test_php.sh.
* Fix for the broken macOS tests.
* Move all jobs to use php80 instead of lots of separate jobs.
* Only pass -t flag if we are running in a terminal.
* Updated php_all job to use new Docker stuff.
* Fixed PHP memory leaks and arginfo errors (#8614)
* Fixed a bunch of incorrect arginfo and a few incorrect error messages.
* Passes mem check test with no leaks!
* WIP.
* Fix build warning that was causing Bazel build to fail.
* Added compatibility code for PHP <8.0.
* Added test_valgrind target and made tests Valgrind-clean.
* Updated Valgrind test to fail if memory leaks are detected.
* Removed intermediate shell script so commands are easier to cut, paste, and modify.
* Passing all Valgrind tests!
* Hoist addref into ObjCache_Get().
* Removed special case of map descriptors by keying object map on upb_msgdef.
* Removed all remaining RETURN_ZVAL() macros.
* Removed all explicit reference add/del operations.
* Added REFCOUNTING.md to Makefile.am.
* Updated upb version and fixed PHP to not get unset message field. (#8621)
* Updated upb version and fixed PHP to not get unset message field.
* Updated changelog.
* Fixed preproc test to handle old versions of Clang withot __has_attribute().
* A second try at fixing __has_attribute().
* Copy __has_attribute() fix to cc file also.
* Updated failure list for PHP for fixed test.
* Updated version of upb for Ruby (#8624)
* Updated upb.
* Preserve legacy behavior for unset messages.
* Updated failure list.
* Updated CHANGES.txt.
* Added erroneously-deleted test file.
* Fixed condition on compatibility code.
* Re-introduced deleted file again, and fixed Rakefile to not delete it.
* Fix generation of test protos.
* Fixed a bunch of incorrect arginfo and a few incorrect error messages.
* Passes mem check test with no leaks!
* WIP.
* Fix build warning that was causing Bazel build to fail.
* Added compatibility code for PHP <8.0.
* Added test_valgrind target and made tests Valgrind-clean.
* Updated Valgrind test to fail if memory leaks are detected.
* Removed intermediate shell script so commands are easier to cut, paste, and modify.
* Passing all Valgrind tests!
* Hoist addref into ObjCache_Get().
* Removed special case of map descriptors by keying object map on upb_msgdef.
* Removed all remaining RETURN_ZVAL() macros.
* Removed all explicit reference add/del operations.
* Added REFCOUNTING.md to Makefile.am.
* Simplified PHP testing setup.
- Consolidated on a single autoloader, created by composer.
- Consolidated on a single phpunit invocation strategy: we run
phpunit on a directory, which will run all tests matching *Test.php
in that directory.
- We now rely on autoloading to import all test protos. require_once()
calls for test protos are removed.
- For now the valgrind tests are removed. A follow-up PR will re-enable
them in a more robust way.
* More improvements to PHP testing.
1. Replace custom PHPUnit-selection logic in test.sh with generic
composer version selection.
2. Optimized both test proto generation and the custom extension
build to avoid unnecessary work when the files are already up
to date.
* Added assertions to verify that the C test doesn't use PHP sources.
* Updated tests.sh for the new PHP testing commands.
* Removed obsolete rules from tests.sh.
* Fixed generate_test_protos.sh for when tmp does not exist.
Also removed undefined_test.php and fixed Makefile.am.
* Added php8.0_all again which is still used.
* Added missing file to Makefile.am.
* Re-added php_all_32 rule which is also still used.
* Updated testing commands for macOS and download composer.
* Use /usr/local/bin on mac instead of /usr/bin, since the latter is not writable.
* Port for php8
* Port php c extension for php8
* Update composer.json
* Drop php7.0 support
* Update phpunit for php7.1 in c extension test
* Add back support for php7.0
* Add badge for php8 continuous build
* De-duplicated code to generate PHP protos and install phpunit.
* Removed all references to generate_php_test_proto.
* Replaced with internal_build_cpp.
* Make Timestamp::__construct() static to avoid conflicts with MongoDB.
* Replicated PHPUnit versions and added new script to Makefile.am.
* Fixed filename in Makefile.am.
* Disabled test that SEGV's on macOS.
* Removed extraneous "set -e".
* Make sure generate_protos.sh happens on every test path.
* Removed stray '$' chars.
* Added proper support for aggregate_metadata tests. But now I get a stack overflow.
Stack overflow:
/Users/haberman/code/protobuf/php/tests/generated/GPBMetadata/Proto/TestDescriptors.php:16
/Users/haberman/code/protobuf/php/tests/generated/GPBMetadata/Proto/TestDescriptors.php:16
/Users/haberman/code/protobuf/php/tests/generated/GPBMetadata/Proto/TestDescriptors.php:16
/Users/haberman/code/protobuf/php/tests/generated/GPBMetadata/Proto/TestDescriptors.php:16
/Users/haberman/code/protobuf/php/tests/generated/GPBMetadata/Proto/TestDescriptors.php:16
/Users/haberman/code/protobuf/php/tests/generated/GPBMetadata/Proto/TestDescriptors.php:16
/Users/haberman/code/protobuf/php/tests/generated/GPBMetadata/Proto/TestDescriptors.php:16
/Users/haberman/code/protobuf/php/tests/generated/GPBMetadata/Proto/TestDescriptors.php:16
namespace GPBMetadata\Proto;
class TestDescriptors
{
public static $is_initialized = false;
public static function initOnce() {
$pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
if (static::$is_initialized == true) {
return;
}
\GPBMetadata\Proto\TestDescriptors::initOnce();
$pool->internalAddGeneratedFile(hex2bin(
""
), true);
static::$is_initialized = true;
}
}
* Fixed and verified metadata aggregation testing.
Instead of calling initOnce of dependencies, initialize metadata of dependencies in the same file.
Needs to pass aggregate_metadata option to protoc to trigger, e.g.:
--php_out=aggregate_metadata=foo#bar:generated_dir
For each input file, transitive dependencies (including itself), whose package name has the prefix of foo or bar, will be aggregated, in which their metadata string will be aggregated in the same internalAddGeneratedFile call. For other dependencies, initOnce is called as before.
This feature is EXPERIMENTAL. DO NOT USE!!!
Instead of calling initOnce of dependencies, initialize metadata of dependencies in the same file.
Needs to pass aggregate_metadata option to protoc to trigger, e.g.:
--php_out=aggregate_metadata=foo#bar:generated_dir
For each input file, transitive dependencies (including itself), whose package name has the prefix of foo or bar, will be aggregated, in which their metadata string will be aggregated in the same internalAddGeneratedFile call. For other dependencies, initOnce is called as before.
This feature is EXPERIMENTAL. DO NOT USE!!!
* Add support for primitive types in setters
* Update to address PR feedback
* Add tests and fixes for repeated fields
* Remove repeated field code, add getters
* Cleanup, test getters and oneofs
* Move boxing logic into separate class
* Add tests for wrapper type constructor args
* Update to add new setXXXValue methods
* Fix tests for invalid values
* Fix c extension for wrapper accessors
* Fix the bug that well known types didn't call Message_construct
* Address PR comments
* Refactoring init message with array logic
* Add include path to protoc
* Add missing TSRM_LS defintion
* Fix TSRM_LS
* Fix dist check
* Prevents installation of `phpunit/phpunit:^6` because the test cases in this project require `\PHPUnit_Framework_TestCase` which was removed in v6. Moves generated PHP classes for tests into autoload-dev so that they are not referenced in the dist autoload. Adds Composer scripts to run protoc with and without grpc.
* update composer test target to use the same commands as generate_php_test_proto in tests.sh
* Add descriptors test
* Update descriptors tests
* Add public descriptors
* Add test_desriptors.proto to test script
* Update composer files
* Remove references to GPBType, update tests to be compatible with c
* Update for c extension compatibility
* Remove nested enums for descriptor, update tests
* Strip leading '.' from descriptor name
* Update tests with test for getClass, fix OneofDescriptor
* Add new files to Makefile.am
* Follows proper autoloading standards
- Splits PHP classes in descriptor.php into separate files
- Splits MapFieldIter and RepeatedFieldIter into separate files
- Moves descriptor.php to Internal/functions.php
- Moves all namespaced functions into Iternal/functions.php
* fixes Makefile.am for added php files
* [PHP] moves all functions to GPBUtil
* removes description.php from the makefile