[英]Laravel URL depends of the environment
The question is simple, I'm building my app with laravel 5.6 I have a lot of <a>
tags and I would like to know if there is a simple way to difference the href field depending on the environment I'm working with. 问题很简单,我正在使用laravel 5.6构建我的应用程序,我有很多<a>
标记,我想知道是否有一种简单的方法可以根据所使用的环境来区分href字段。
An example would be easy to understand. 一个例子很容易理解。 If I'm working in dev environment the prefix would be http://localhost:3000 如果我在开发环境中工作,则前缀为http:// localhost:3000
If I'm working in prod stage the prefix should look like https://myapp.com 如果我在产品开发阶段工作,则前缀应类似于https://myapp.com
So when I build the href 所以当我建立href
<a href = {{ somefunction('/foo/bar') }}></a>
So, some function
will just construct a valid URL depending on the environment. 因此, some function
将根据环境构建一个有效的URL。
Yup. 对。 The url
helper , included with Laravel. Laravel随附的url
helper 。
There's also route()
for named routes , which can be very useful. 还有用于命名路由的route()
,它可能非常有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.