Laravel 5 config / app.php url设置

时间:2021-09-08 11:20:03

This issue became apparent for me when using dynamic routes within scheduled emails. The email url's are built with this config setting which apparently is not setup to adjust to the server environment. I am using Forge for production. What is best practice for configuring this attribute? Would I add a variable to env files?

在计划的电子邮件中使用动态路由时,这个问题对我来说很明显。电子邮件网址是使用此配置设置构建的,显然未设置为适应服务器环境。我正在使用Forge进行生产。配置此属性的最佳做法是什么?我会为env文件添加一个变量吗?

Currently its set as follow:

目前其设定如下:

'url' => 'http://localhost',

2 个解决方案

#1


I use Forge as my production also. Everything works for me. I have my settings like this :

我也使用Forge作为我的作品。一切都适合我。我有这样的设置:

In my config\app.php

在我的config \ app.php中

I set my 'url' => env('DB_HOST'),

我设置了'url'=> env('DB_HOST'),

DB_HOST : is just the IP Address to your server.

DB_HOST:只是服务器的IP地址。

and that should match with your .env file on your Production Server.

这应该与您的Production Server上的.env文件相匹配。

My .env look something like this :

我的.env看起来像这样:

APP_ENV=production
APP_DEBUG=false
APP_KEY=******************

DB_HOST= http://12.23.29.122/
DB_DATABASE=db-name
DB_USERNAME=forge
DB_PASSWORD=**************

Hope this help !

希望这有帮助!

#2


If your website will be not installed on other domain, then you can assign it via config file directly:

如果您的网站未安装在其他域上,则可以直接通过配置文件进行分配:

'url' => 'http://localhost',

If your application will be installed/ran in different enviroments or domain you can set it via .env file:

如果您的应用程序将在不同的环境或域中安装/运行,您可以通过.env文件进行设置:

# .env file
APP_URL=http://localhost

#1


I use Forge as my production also. Everything works for me. I have my settings like this :

我也使用Forge作为我的作品。一切都适合我。我有这样的设置:

In my config\app.php

在我的config \ app.php中

I set my 'url' => env('DB_HOST'),

我设置了'url'=> env('DB_HOST'),

DB_HOST : is just the IP Address to your server.

DB_HOST:只是服务器的IP地址。

and that should match with your .env file on your Production Server.

这应该与您的Production Server上的.env文件相匹配。

My .env look something like this :

我的.env看起来像这样:

APP_ENV=production
APP_DEBUG=false
APP_KEY=******************

DB_HOST= http://12.23.29.122/
DB_DATABASE=db-name
DB_USERNAME=forge
DB_PASSWORD=**************

Hope this help !

希望这有帮助!

#2


If your website will be not installed on other domain, then you can assign it via config file directly:

如果您的网站未安装在其他域上,则可以直接通过配置文件进行分配:

'url' => 'http://localhost',

If your application will be installed/ran in different enviroments or domain you can set it via .env file:

如果您的应用程序将在不同的环境或域中安装/运行,您可以通过.env文件进行设置:

# .env file
APP_URL=http://localhost