Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

faizi_856's avatar

How to set json file path in .env file for google api credentials, in production

I'm trying to use Google speech to text api. And I'm unable to set the json file path in .env for Google credentials, on production.

While in local server, it is working properly but I don't know how to do it in production.

I have placed the json file in public folder but it is giving an error.

If anybody know the solution, kindly do comment. I need it urgently.

0 likes
12 replies
Sinnbeck's avatar

Show what you have. Any reason for putting it in public? You want people to steal your credentials? Put them in storage

faizi_856's avatar

@sinnbeck initially i put it in storage folder....but just moved it to public for testing when google failed to get JSON file.

I just need to know how to give path of JSON file, i can always change locations

in ENV, i am putting it like this

GOOGLE_APPLICATION_CREDENTIALS="be374f9c211f.json"

ant the error i am getting is

Google\ApiCore\ValidationException: Could not construct ApplicationDefaultCredentials in file /.../.../vendor/google/gax/src/CredentialsWrapper.php on line 271

Sinnbeck's avatar

@faizi_856 ok so something like this it seems. Assuming file is in /storage/app

GOOGLE_APPLICATION_CREDENTIALS="/complete/path/to/project/storage/app/be374f9c211f.json 
faizi_856's avatar

@Sinnbeck i know how to find the project path in cpanel but this website is running in plesk...so i dont know exactly how to get project path Could you guide me?

Sinnbeck's avatar

@Jonjie What root directory? The base of the laravel install? if so, then yes it should be (as long as the webserver is pointed to /public)

Randy_Johnson's avatar

@Jonjie push app root to github, ssh into server, git clone the app, create soft link ln -s /app/public public_html.

Folder structure will be like this

/domain
/public_html <- softlink to public inside app, when user goes to url, they are directed into here by the server, and then it looks for the index.php
/app <- all laravel files in here
faizi_856's avatar

@sathish-SEET what i am facing issue where to put the file? like in public folder or in some storage folder and then how to give its absolute path in env..because it is not working and the thread you provided link of..i have already visited it

Please or to participate in this conversation.