Hi,
I've been struggling today with a really weird issue. I think I narrowed it down to this repository, but if it is not applicable here, please let me know.
I've been trying to use the RecaptchaEnterprise package, however when I try to use it, I get the following error:
Class "GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise" not found
"file":
"/var/www/html/vendor/google/cloud-recaptcha-enterprise/src/V1/Event.php:179",
Which is thrown when this line of code is executed:
$event = new \Google\Cloud\RecaptchaEnterprise\V1\Event(['']);
I debugged this further, making sure everything is installed. The strange thing is that Composer correctly loads the class (ClassLoader::loadClass
does not return an error), but class_exists()
that returns false
As an experiment I copied the Recaptchaenterprise class to my own code, and aliased it, but then the error message went one step down:
\"GPBMetadata\\Google\\Api\\Http\" not found",
"/var/www/html/vendor/google/common-protos/metadata/Api/Annotations.php:17",
I then made a script that only includes the autoloader, and only calls class_exists
. No code should be executed would be my thought.
<?php
require \dirname(__DIR__).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
$classes = [
'GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise',
'GPBMetadata\Google\Api\FieldBehavior',
'GPBMetadata\Google\Api\Http',
'GPBMetadata\Google\Api\Backend',
'GPBMetadata\Google\Type\Latlng'
];
foreach ($classes as $class) {
echo $class. ' ' . var_export(class_exists($class), true).PHP_EOL;
}
But the output of this script contains a bunch weird characters.. some kind of encoding issue?
$ php test.php
㰿灨瀊⌠䝥湥牡瑥搠批⁴桥⁰牯瑯捯氠扵晦敲䵥瑡 ... etc
But where does this output come from? I'm only calling class_exists?
For every class where class_exists
returns false, this weird output is there. Some classes from this repo are correctly loaded. It seems that most classes in Api
fail, but for example classes in Type
, like GPBMetadata\Google\Type\Latlng
succeed.
If I manually call include dirname(__DIR__).'/vendor/google/common-protos/metadata/Api/Http.php';
, I get the same weird output, so it seems that simply the act of including one of these files generates some output.
Any help here? I have no idea what is causing this. I have not found any similar issues in any of the repo's. I'd have to guess it would some configuration issue, perhaps in my php.ini but I have no idea what.
Versions:
- PHP version PHP 8.1.4 (docker image)
google/cloud-recaptcha-enterprise
1.8.1
google/common-protos
4.5.0