Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

405
Visualizações
How to access the laravel .env variables inside itself

I need to ask stupid question but my question to access .env variable inside it self not from php :

If i have .env file for larvel5.4 and i have APP_URL Like this :

APP_ENV=local
APP_KEY=base64:7qLJMqTxrAPk+tLJscVlmrzf2H16tAfbSoCZuleCkxQ=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

and i have multi config variable use the domain link like this :

#Facebook

FACEBOOK_LOGIN_URL=http://localhost:8000/en/portal/facebook_login
FACEBOOK_CALLBACK_URL=http://localhost:8000/en/portal/facebook_callback

#Twitter

TWITTER_LOGIN_URL=http://localhost:8000/en/portal/twitter_login
TWITTER_CALLBACK_URL=http://localhost:8000/en/portal/twitter_callback

#Google

GOOGLE_LOGIN_URL=http://localhost:8000/en/portal/google_login
GOOGLE_CALLBACK_URL=http://localhost:8000/en/portal/google_callback

is there way to access the APP_URL in the same file like this :

FACEBOOK_LOGIN_URL= APP_URL /en/portal/facebook_login

Please i am new member don't give me minus for this question.

Thank you all

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You can keep things simple, while accessing ENV variables you can easily do the following:

Env file:

APP_URL=http://localhost:8000
FACEBOOK_LOGIN_URL=/en/portal/facebook_login
FACEBOOK_CALLBACK_URL=/en/portal/facebook_callback

in Laravel:

env('APP_URL') . env('FACEBOOK_LOGIN_URL');

And Yes we can do that if needed use following syntax:

.env file:

APP_URL=http://localhost:8000
FACEBOOK_LOGIN_URL=${APP_URL}/en/portal/facebook_login
FACEBOOK_CALLBACK_URL=${APP_URL}/en/portal/facebook_callback
over 4 years ago · Santiago Trujillo Relatório

0

While other answers are correct about using variables stored in .env. I think it's going to be neater, if you do the following:

url(env('FACEBOOK_LOGIN_URL'))

or:

url(env('FACEBOOK_CALLBACK_URL'))

url() uses APP_URL so you don't need to concatenate your .env variables.

over 4 years ago · Santiago Trujillo Relatório

0

In .env file:

APP_URL=http://localhost:8000
FACEBOOK_LOGIN_URL="${APP_URL}/en/portal/facebook_login"
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda