LaraBABA's avatar

Unable to access a json file in the app root

Hello,

I am having a strange problem.

I am using the google api which uses a json credentials files.

I added this file in the app root(where the .env file resides).

On windows, everything works as expected and the below code manages to access the json file. But as soon as I upload my script onto a centos server, the Laravel logs shows that the credential file is not found in this location. But I can assure you that the file has bee uploaded to the same spot.

Here is the line of code that causes me problem in both OS:

putenv('GOOGLE_APPLICATION_CREDENTIALS=../XXXXXXXXa8006b.json');

On windows ok, on Centos OS, it does not work.

Any idea why please?

Thank you.

0 likes
2 replies
bobbybouwmann's avatar

../ indicates that the file is in the parent directory. So if it's placed in the same file as the .env this shouldn't match right?

Another option is being really specific about the location of the file

putenv('GOOGLE_APPLICATION_CREDENTIALS=/home/user/www/XXXXXXXXa8006b.json');
Snapey's avatar

pay attention to the letter case of the filename. you are moving from case insensitive to case sensitive OS

Please or to participate in this conversation.