googleads / google-ads-php

Google Ads API Client Library for PHP
https://developers.google.com/google-ads/api/docs/client-libs/php
Apache License 2.0
288 stars 260 forks source link

Google API V15 Fatal error: Trait "Google\ApiCore\ResourceHelperTrait" not found in GoogleAdsServiceClient.php on line 64 #970

Closed resourcinity closed 9 months ago

resourcinity commented 9 months ago

Your client library and Google Ads API versions:

Your environment:

================= PHP GENERAL INFORMATION phpinfo() PHP Version => 8.1.25

System => Linux cloud.uptoss.com 3.10.0-1160.59.1.el7.x86_64 #1 SMP Wed Feb 23 16:47:03 UTC 2022 x86_64 Build Date => Oct 24 2023 21:51:16 Build System => Red Hat Enterprise Linux Server release 7.9 (Maipo) Build Provider => Remi's RPM repository https://rpms.remirepo.net/ #StandWithUkraine Compiler => gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11) Architecture => x86_64 Server API => Command Line Interface Virtual Directory Support => disabled Configuration File (php.ini) Path => /etc/opt/remi/php81 Loaded Configuration File => /etc/opt/remi/php81/php.ini Scan this dir for additional .ini files => /etc/opt/remi/php81/php.d Additional .ini files parsed => /etc/opt/remi/php81/php.d/01-ioncube_loader.ini, /etc/opt/remi/php81/php.d/10-opcache.ini, /etc/opt/remi/php81/php.d/20-bcmath.ini, /etc/opt/remi/php81/php.d/20-bz2.ini, /etc/opt/remi/php81/php.d/20-calendar.ini, /etc/opt/remi/php81/php.d/20-ctype.ini, /etc/opt/remi/php81/php.d/20-curl.ini, /etc/opt/remi/php81/php.d/20-dom.ini, /etc/opt/remi/php81/php.d/20-enchant.ini, /etc/opt/remi/php81/php.d/20-exif.ini, /etc/opt/remi/php81/php.d/20-fileinfo.ini, /etc/opt/remi/php81/php.d/20-ftp.ini, /etc/opt/remi/php81/php.d/20-gd.ini, /etc/opt/remi/php81/php.d/20-gettext.ini, /etc/opt/remi/php81/php.d/20-iconv.ini, /etc/opt/remi/php81/php.d/20-imap.ini, /etc/opt/remi/php81/php.d/20-intl.ini, /etc/opt/remi/php81/php.d/20-mbstring.ini, /etc/opt/remi/php81/php.d/20-mysqlnd.ini, /etc/opt/remi/php81/php.d/20-pdo.ini, /etc/opt/remi/php81/php.d/20-pgsql.ini, /etc/opt/remi/php81/php.d/20-phar.ini, /etc/opt/remi/php81/php.d/20-posix.ini, /etc/opt/remi/php81/php.d/20-pspell.ini, /etc/opt/remi/php81/php.d/20-shmop.ini, /etc/opt/remi/php81/php.d/20-simplexml.ini, /etc/opt/remi/php81/php.d/20-soap.ini, /etc/opt/remi/php81/php.d/20-sockets.ini, /etc/opt/remi/php81/php.d/20-sodium.ini, /etc/opt/remi/php81/php.d/20-sqlite3.ini, /etc/opt/remi/php81/php.d/20-sysvmsg.ini, /etc/opt/remi/php81/php.d/20-sysvsem.ini, /etc/opt/remi/php81/php.d/20-sysvshm.ini, /etc/opt/remi/php81/php.d/20-tidy.ini, /etc/opt/remi/php81/php.d/20-tokenizer.ini, /etc/opt/remi/php81/php.d/20-xml.ini, /etc/opt/remi/php81/php.d/20-xmlwriter.ini, /etc/opt/remi/php81/php.d/20-xsl.ini, /etc/opt/remi/php81/php.d/30-mcrypt.ini, /etc/opt/remi/php81/php.d/30-mysqli.ini, /etc/opt/remi/php81/php.d/30-pdo_mysql.ini, /etc/opt/remi/php81/php.d/30-pdo_pgsql.ini, /etc/opt/remi/php81/php.d/30-pdo_sqlite.ini, /etc/opt/remi/php81/php.d/30-xmlreader.ini, /etc/opt/remi/php81/php.d/30-xmlrpc.ini, /etc/opt/remi/php81/php.d/30-zip.ini, /etc/opt/remi/php81/php.d/40-grpc.ini, /etc/opt/remi/php81/php.d/40-igbinary.ini, /etc/opt/remi/php81/php.d/40-imagick.ini, /etc/opt/remi/php81/php.d/40-mailparse.ini, /etc/opt/remi/php81/php.d/40-msgpack.ini, /etc/opt/remi/php81/php.d/40-protobuf.ini, /etc/opt/remi/php81/php.d/50-memcached.ini

PHP API => 20210902 PHP Extension => 20210902 Zend Extension => 420210902 Zend Extension Build => API420210902,NTS PHP Extension Build => API20210902,NTS Debug Build => no Thread Safety => disabled Zend Signal Handling => enabled Zend Memory Manager => enabled Zend Multibyte Support => provided by mbstring Zend Max Execution Timers => disabled IPv6 Support => enabled DTrace Support => available, disabled

Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, compress.bzip2, phar, zip Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2 Registered Stream Filters => zlib., string.rot13, string.toupper, string.tolower, convert., consumed, dechunk, bzip2., convert.iconv., mcrypt., mdecrypt.

This program makes use of the Zend Scripting Language Engine: Zend Engine v4.1.25, Copyright (c) Zend Technologies with the ionCube PHP Loader v13.0.2, Copyright (c) 2002-2023, by ionCube Ltd. with Zend OPcache v8.1.25, Copyright (c), by Zend Technologies ================= PHP EXTENSION INFORMATION The PHP Extension grpc is installed: 1.59.1 The PHP Extension protobuf is installed: 3.25.1

Description of the bug: I have done a fresh install using composer require and have verified my server has grpc and protobuf extensions installed.

I haven't changed anything with the example except to put in my google ads client id for the GetCampaigns.php example.

So I am running on the CLI: php81 -d display_errors=on examples/BasicOperations/GetCampaigns.php and it returns this error: Fatal error: Trait "Google\ApiCore\ResourceHelperTrait" not found in /...redacted..../GoogleAdsServiceClient.php on line 64

Even stranger is that I created a local dev setup and installed the library and phpstorm successfully locates the ResourceHelperTrait and all the namespaces mentioned in GetCampaigns.php are also located.

I attempted to downgrade gax several versions earlier to see if it fixed anything but it didn't.

Steps to reproduce:

Expected behavior:

Anything else we should know about your project / environment: I duplicated the entire setup locally using a windows binary of php and got the same error.

fiboknacky commented 9 months ago

Even stranger is that I created a local dev setup and installed the library and phpstorm successfully locates the ResourceHelperTrait and all the namespaces mentioned in GetCampaigns.php are also located.

  1. So, you mean PHPStorm can locate the file but it fails when you run the example in command prompt?
  2. What's the gax version you installed?
  3. You ran composer require at your project's root directory, right? Can you show me more how your vendor looks like?
resourcinity commented 9 months ago
  1. Yes that's correct
  2. right now its at 1.24
  3. no. maybe I'll try running it in the root. Right now project structure is as follows: project root is here: C:\Users\redacted\SynologyDrive\Ampps\www\rc.com\list and vendor is located in C:\Users\redacted\SynologyDrive\Ampps\www\rc.com\list\adv here is print out of vendor: https://skyguy.tinytake.com/msc/ODk1MzI1N18yMjQyODA1NA
fiboknacky commented 9 months ago

Hmm.. From your screenshot, I don't see this library is installed properly yet. There is only googleads-php-lib, which is Google Ad Manager SOAP API Client Library for PHP.

resourcinity commented 9 months ago

ok I re-ran composer require googleads/google-ads-php from the adv directory and re-ran the GetCampaigns.php and still got same error. The below path is where gax is and ResourceHelperTrait.php

C:\Users\redacted\SynologyDrive\Ampps\www\rc.com \list\adv\vendor\google\gax\src\ResourceHelperTrait.php

What should I do at this point?

Should I start a brand new project and put vendor at the root of the project?

On Mon, Nov 20, 2023 at 11:34 PM Thanet Knack Praneenararat < @.***> wrote:

Hmm.. From your screenshot, I don't see this library is installed properly yet. There is only googleads-php-lib, which is Google Ad Manager SOAP API Client Library for PHP.

— Reply to this email directly, view it on GitHub https://github.com/googleads/google-ads-php/issues/970#issuecomment-1820319752, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRMLWKTQZGAW5YT7KYE6DDYFRDPHAVCNFSM6AAAAAA7T7RSMOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRQGMYTSNZVGI . You are receiving this because you authored the thread.Message ID: @.***>

resourcinity commented 9 months ago

Another potential issue is the google_ads_php.ini file I am using is using a manager account and a linked account: loginCustomerId = "888888999" linkedCustomerId = "4444444444"

Do you know if this is still supported? Or would it have thrown an authentication error ?

fiboknacky commented 9 months ago

You can comment out those customer IDs first too, but I don't think it's a source of error.

project root is here: C:\Users\redacted\SynologyDrive\Ampps\www\rc.com\list and vendor is located in C:\Users\redacted\SynologyDrive\Ampps\www\rc.com\list\adv

If the root is ...\list, why is your vendor installed under ...\list\adv? If you run composer require, I believe it should be installed directly under ...\list.

resourcinity commented 9 months ago

I got this fixed by following the install instructions exactly. Then had another issue with authentication. Instead of using login-customer-id (manager acct) plus linked-customer-id (customer acct), I had to use login-customer-id (manager) and customer-id (customer). So in the google_ads_php.ini authentication file I used: loginCustomerId = "xxxxxxxxx" customerId = "yyyyyyyyyy"

Thanks for the help!

fiboknacky commented 9 months ago

The login-customer-id doesn't need to be used with linked-customer-id. Regarding how to use those parameters to send a request to the API server, could you please ask on the Google Ads API forum? Thanks.