You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating object of class PubSubClient when PUBSUB_EMULATOR_HOST is set produces Class "Grpc\ChannelCredentials" not found when grcp extension is not installed
#8052
Open
botzkobg opened this issue
Jan 28, 2025
· 0 comments
This commit adds a method called setDefaultEmulatorConfig() to all affected classes to set $options['transportConfig']['grpc']['stubOpts']['credentials'] but the code doesn't check if Grpc\ChannelCredentials exits.
To resolve the issue before a new version with a fix is released you can create a stub (grpc.php.stub) and load it before creating any of the affected objects:
<?php/** * PubSubClient assumes that if the PUBSUB_EMULATOR_HOST env var is set that the grpc extension is installed :( */declare(strict_types=1);
namespaceGrpc;
if (! class_exists('Grpc\ChannelCredentials')) {
class ChannelCredentials {
publicstaticfunctioncreateInsecure(): null
{
returnnull;
}
}
}
Environment details
Steps to reproduce
php
without installinggrcp
extensionPubSubClient
when env varPUBSUB_EMULATOR_HOST
is setCode example
Other affected classes
This was introduced by PR https://github.com/googleapis/google-cloud-php/pull/8043/files#diff-7531da9182e8b27adc9c92152bb021494ed2dde7cfb50433a16d8adbcce60518 and more specifically commit googleapis/google-cloud-php-pubsub@7b2d692
This commit adds a method called
setDefaultEmulatorConfig()
to all affected classes to set$options['transportConfig']['grpc']['stubOpts']['credentials']
but the code doesn't check ifGrpc\ChannelCredentials
exits.Workaround
Source: #7187 (comment)
To resolve the issue before a new version with a fix is released you can create a stub (
grpc.php.stub
) and load it before creating any of the affected objects:The text was updated successfully, but these errors were encountered: