Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

404
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

0

In .env file:

APP_URL=http://localhost:8000
FACEBOOK_LOGIN_URL="${APP_URL}/en/portal/facebook_login"
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda