0

I'm using Laravel 8.0 in my application and I added a new .env variable:

APP_URL_FRONT=https://tmsv00008:6204 

And how I use it:

To access the project use the following link: <a href="{{ env('APP_URL_FRONT') }}/projects/{{ $project->id }}">LINK</a> 

When I deploy the application I cache the config files:

php artisan config:cache 

But the env files is not visible and the strange thing is that if I execute:

php artisan config:clear 

The variable is visible. What I'm doing wrong? Because it doesn't make sense to me.

Also, in this article they suggest to execute the commands in this order:

php artisan config:cache php artisan config:clear 

But this doesn't make sense to me. Shouldn't be the other way around? And I think the cache commands also clears the cache first.

1 Answer 1

2

The env() function is strongly recommended to be used only in configuration file, since caching the configurations, will make the env function to return null

In other words, crate a configuration file, with that environment variable, or add it to an existing one

It's hidden in an old update guide this "note"

Sign up to request clarification or add additional context in comments.

4 Comments

Or can I use other function?
@NicuVlad mmm no... my suggestion is to add to an existing file (like the app one)and then use config('app.url_front)
Got it. Let me try
It worked! Tx!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.