Location of adsapi_php.ini

1,902 views
Skip to first unread message

Marty G

unread,
Feb 26, 2018, 5:17:04 AM2/26/18
to AdWords API Forum
HI Guys

I've been using the Adwords API for around a year or so, I always used the auth.ini file on each api update we managed to get it working
but recently we upgraded to the latest API, using composer to install to our classes folder C:\xampp\htdocs\main-application\classes\
to which we have the vendor folder & other folders needed to run the api, I've filled out the adsapi_php.ini with our project details, but while running our test file we encounter the fatal error & missing ini file.

I printed the $_SERVER output in order to find the home directory & tried re-locating the ini file to various locations on the server install, but still get the fatal error

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Config file not found as specified: 'adsapi_php.ini'.
Home directory could not be located so it was not searched.' in C:\xampp\htdocs\main-application\classes\google-adwords\vendor\googleads\googleads-php-lib\src\Google\AdsApi\Common\ConfigurationLoader.php on line 77

Array
(
[MIBDIRS] => C:/xampp/php/extras/mibs
[MYSQL_HOME] => \xampp\mysql\bin
[OPENSSL_CONF] => C:/xampp/apache/bin/openssl.cnf
[PHP_PEAR_SYSCONF_DIR] => \xampp\php
[PHPRC] => \xampp\php
[TMP] => \xampp\tmp
[HTTP_HOST] => localhost
[HTTP_CONNECTION] => keep-alive
[HTTP_UPGRADE_INSECURE_REQUESTS] => 1
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
[HTTP_ACCEPT_ENCODING] => gzip, deflate, br
[HTTP_ACCEPT_LANGUAGE] => en-GB,en-US;q=0.9,en;q=0.8
[PATH] => C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Skype\Phone\;
[SystemRoot] => C:\Windows
[COMSPEC] => C:\Windows\system32\cmd.exe
[PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
[WINDIR] => C:\Windows
[SERVER_SIGNATURE] => Apache/2.4.12 (Win32) OpenSSL/1.0.1l Server at localhost Port 80
[SERVER_SOFTWARE] => Apache/2.4.12 (Win32) OpenSSL/1.0.1l
[SERVER_NAME] => localhost
[SERVER_ADDR] => ::1
[SERVER_PORT] => 80
[REMOTE_ADDR] => ::1
[DOCUMENT_ROOT] => C:/xampp/htdocs
[REQUEST_SCHEME] => http
[CONTEXT_PREFIX] =>
[CONTEXT_DOCUMENT_ROOT] => C:/xampp/htdocs
[SERVER_ADMIN] => testsupport @ test.co.uk
[SCRIPT_FILENAME] => C:/xampp/htdocs/main-application/test/test-adwords.php [REMOTE_PORT] => 61099 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /
[REMOTE_PORT] => 61099
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /
[REMOTE_PORT] => 61099
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /main-application/test/test-adwords.php
[SCRIPT_NAME] => /main-application/test/test-adwords.php
[PHP_SELF] => /main-application/test/test-adwords.php
[REQUEST_TIME_FLOAT] => 1519638340.619
[REQUEST_TIME] => 1519638340
) 

I've tried locating our ini file to:
  • C:\xampp\htdocs\
  • C:\xampp\htdocs\main-application\
  • C:\xampp\htdocs\main-application\classes\
  • C:\xampp\htdocs\main-application\classes\google-adwords
  • C:\xampp\htdocs\main-application\classes\google-adwords\vendor\

Still getting the same error..!


Cheers

Dhanya Sundararaju (AdWords API Team)

unread,
Feb 26, 2018, 1:10:25 PM2/26/18
to AdWords API Forum
Hi Marty,

You would need to copy down the adsapi_php.ini to your home directory. To find your home directory, please run this sample code and let me know if you have further questions.

Regards,
Dhanya, AdWords API Team

Marty G

unread,
Feb 28, 2018, 10:17:23 AM2/28/18
to AdWords API Forum
Hi Dhanya

many thanks for the reply...

I've ran the example code but this throws the error

Could not locate home directory.

I'm currently running the the api via a windows xampp install (where I've been running it previously for over a year)

so unsure as what to try next?

thanks

Marty

Marty G

unread,
Feb 28, 2018, 11:16:38 AM2/28/18
to AdWords API Forum
I just wanted to add that I've tried the EnviromentTest on my remote Apache shared server & this also throws the exception 

could not located home directory

I know running the class file, is looking for variations of the home directory
  • getenv('HOME')
  • getenv('HOMEDRIVE')
  • getenv('HOMEPATH')
print_r($_SERVER)

Array
(
    [CONTEXT_DOCUMENT_ROOT] => /home/testsite/public_html
[CONTEXT_PREFIX] => [DOCUMENT_ROOT] => /home/testsite/public_html
[GATEWAY_INTERFACE] => CGI/1.1 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_ACCEPT_LANGUAGE] => en-GB,en-US;q=0.9,en;q=0.8,fr;q=0.7 [HTTP_CACHE_CONTROL] => max-age=0 [HTTP_CONNECTION] => keep-alive [HTTP_COOKIE] => _jsuid=4094727426; _ga=GA1.3.1583573795.1519032551; wp-settings-1=editor%3Dhtml%26libraryContent%3Dbrowse%26crawl_category_tab%3Dpop%26posts_list_mode%3Dlist%26mfold%3Do; wp-settings-time-1=1519129313 [HTTP_HOST] => testsite.co.uk
[HTTP_UPGRADE_INSECURE_REQUESTS] => 1 [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36 [PATH] => /bin:/usr/bin [QUERY_STRING] => [REDIRECT_STATUS] => 200 [REMOTE_ADDR] => 86.27.46.116 [REMOTE_PORT] => 60200 [REQUEST_METHOD] => GET [REQUEST_SCHEME] => http [REQUEST_URI] => /home-test.php [SCRIPT_FILENAME] => /home/test/public_html/home-test.php
[SCRIPT_NAME] => /home-test.php [SERVER_ADDR] => 72.249.48.7 [SERVER_ADMIN] => webmaster @ testsite.co.uk
[SERVER_NAME] => testsite.co.uk
[SERVER_PORT] => 80 [SERVER_PROTOCOL] => HTTP/1.1 [SERVER_SIGNATURE] => [SERVER_SOFTWARE] => Apache [TZ] => America/Chicago [UNIQUE_ID] => WpbTVqgD0l1Wrj5KH1CUrwAAAAs [PHP_SELF] => /home-test.php [REQUEST_TIME_FLOAT] => 1519833943.0969 [REQUEST_TIME] => 1519833943 
) 

I've added a few lines to the Eviro class 

}else if (!empty($_SERVER['DOCUMENT_ROOT']) ) {
  $home
= $_SERVER['DOCUMENT_ROOT'];
}

this passes the test, because we know the DOCUMENT_ROOT is found in $_SERVER

would it not be better adding this to the API ?

Cheers

Marty

Dhanya Sundararaju (AdWords API Team)

unread,
Feb 28, 2018, 5:00:59 PM2/28/18
to AdWords API Forum
Hi Marty,

As per the README file in the guide, the examples are meant to be run from the command line and not as a webpage. That may be the reason, DOCUMENT_ROOT is not included. Anyhow, glad that it worked. Moving further, within the examples, the builder's fromFile() method looks for an adsapi_php.ini file in your home directory by default. If you want to store this file in another directory, please pass the path of the file as an argument. For example:

fromFile('/config/myprops.ini')

If you still face issues, could you run GetCampaigns.php and send across the complete SOAP logs?
Reply all
Reply to author
Forward
0 new messages