Closed daniel-for-j closed 1 year ago
I solved this by changing
the variable in vonage/client-core/src/Client/Credentials/Container.php from
protected array $credentials;
to
protected array $credentials = []
Hope it helps!
This isn't a bug, more of an implementation problem. The reason the error is thrown is because you haven't passed in environment variables on your server - so the "fix" isn't actually a fix (PHP8 errors if you attempt to initialize a property before it is set, if there is no default).
This means all of your verifications will actually be erroring on the server, and I expect it is because you are using env()
. It is not recommended to use env()
over the Laravel config()
helper - I'd suggest moving these over.
At any rate, the root of the problem is not the library, it's how you fetch credentials.
Verifying a user with Vonage client package on Laravel, everything works fine on local but once I update to the server it throws
"Typed property Vonage\Client\Credentials\Container::$credentials must not be accessed before"
I have updated my .env with
VONAGE_API_KEY='XXXXXX' VONAGE_API_SECRET='XXXXXXXXXXXXXX'
My Controller ` $basic = new Basic(env('VONAGE_API_KEY'),env('VONAGE_API_SECRET')); $client = new Client(new Container($basic)); $otpRequest = new OtpRequest($inputData['mobile_number'], "COMPANY");
`
It breaks at the very second line.
I will appreciate any help rendered