Laravel:db种子文件中不包含本地主机的URL :: to('/')端口号 [英] Laravel: URL::to('/') port number for localhost not included in db seed files

查看:110
本文介绍了Laravel:db种子文件中不包含本地主机的URL :: to('/')端口号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在端口4567上运行本地服务器.我试图这样做,以便在我的数据库播种时,将对网站主页的引用保存在我的数据库中.但是我注意到,当我在种子中运行URL :: to('/')时,它仅包含"localhost"而不包含端口,但是如果我将其包含在视图代码中,则显示为"localhost:4567".为什么是这样?如果可能的话,如何在不编写有关我所处生产环境的语句的情况下,如何解决此问题?谢谢.

I am running a local server on port 4567. I am trying to make it so that when my database seeds I save a reference to the home page on my site in my db. However I noticed when I run URL::to('/') in my seeds it only includes "localhost" without the port, but if I include it in my view code it comes out as "localhost:4567". Why is this? How can I fix it, if possibly, without writing if statement conditionals about what production environment I am in? Thank you.

URL :: to('/')的种子文件结果

Seed File result of URL::to('/')

http://localhost

查看URL :: to('/')的文件结果

View File result of URL::to('/')

http://localhost:4567

推荐答案

在环境文件中设置APP_URL

Either set APP_URL in env file

APP_URL=http://localhost:4567

或在config/app.php中设置网址

Or set url in config/app.php

'url' => env('APP_URL', 'http://localhost:4567'),

这篇关于Laravel:db种子文件中不包含本地主机的URL :: to('/')端口号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆