PHP Fatal error: Trait 'ProtocolTrait' not found

I am using Oauth for gmail account, I followed https://github.com/google/gmail-oauth2-tools/blob/master/php/oauth2.php this link but getting error as below

PHP Fatal error: Trait 'ProtocolTrait' not found in C:\inetpub\wwwroot\bephpforTteam\New\gmailread\vendor\zendframework\zend-mail\src\Protocol\Imap.php on line 16

Please help me

You should follow the introduction: https://github.com/google/gmail-oauth2-tools/wiki/PhpSampleCode
There will you find a complete package for download.

But keep in mind, this is only example code which is based on a very old and unsupported version of Zend Framework (v1). This will not work with the new version without changes.

I followed this tutorial but it gives error as below,

> PHP Fatal error: Uncaught Zend_Mail_Protocol_Exception: cannot connect to host; error = (errno = 0 )

What changes in zend framework are needed to implement oauth2?

Please keep in mind, this is an example from Google and I am not Google. I do not know this example!

No changes in Zend Framework. You must change the example code from Google if this should work if a newer version of ZF.

Try to connect yourself with the IMAP-Server from Google. Install the new version of zend-mail and follow this explanation: https://docs.zendframework.com/zend-mail/read/

Replace the require_once calls at the top with require 'vendor/autoload.php';. No one uses the require hell anymore.

1 Like