11.08.2017 Views

codebright

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

URL Generation<br />

Your web application revolves around routes and URLs. After all, they are what direct your users to<br />

your pages. At the end of the day, serving pages is what any web application must do.<br />

Your users might not be interested for long if you are only serving one page, and if you intend to<br />

move them around your website or web application, then you will need to use a critical feature of<br />

the web. What feature, you ask? Well, hyper-links!<br />

In order to construct hyper links we need to build URLs to our application. We could do them<br />

by hand, but Laravel can save us some effort by providing a number of helpers to assist with the<br />

construction of URLs. Let’s take a look at those features.<br />

The current URL<br />

Getting the current URL in Laravel is easy. Simply use the URL::current() helper. Let’s create a<br />

simple route to test it.<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!