Julian Mendez
Julian Mendez

Reputation: 3372

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.

An example would be easy to understand. If I'm working in dev environment the prefix would be http://localhost:3000

If I'm working in prod stage the prefix should look like https://myapp.com

So when I build the href

<a href = {{ somefunction('/foo/bar') }}></a>

So, some function will just construct a valid URL depending on the environment.

Upvotes: 0

Views: 159

Answers (1)

ceejayoz
ceejayoz

Reputation: 180014

Yup. The url helper, included with Laravel.

There's also route() for named routes, which can be very useful.

Upvotes: 1

Related Questions