Technology Blog

Look deep into latest news and innovations happening in the Tech industry with our highly informational blog.

What are the New Features in Laravel 5.5?

Version 5.5 of Laravel is officially released! This release is jam-packed with goodies and improvements, here’s a quick summarizing the highlight features.

What're new features in Laravel 5.5?

1. New Route Methods introduced in Laravel 5.5

Laravel 5.5 shipped a couple of convenient shortcuts to the Laravel Router class that eliminates the need for creating a controller or closure only to return a simple view or redirect. If you missed them in the release notes, let’s look at them briefly, they are sure to simplify your code and remove a couple of files.

The Route::view method

The Route::view method eliminates the need for routes that only need a view returned. Instead of using a controller or a closure, you can define a URI and a path to a view file:

// resources/views/pages/about.blade.php
Route::view('/about', 'pages.about');

You can also pass in an array of variables that will be passed to the view:

Route::view('/about', 'pages.about', ['year' => date('Y')]);

The Route::redirect Method

The Route::redirect method also eliminates the need to create a controller or a closure only to return a redirect response:

Route::redirect('/old-about', '/about');

The third default argument, if not passed, is a 301 redirect. However, you can pass the third argument for a different status code. For example, if you want to create a 307 Temporary Redirect, it would look like this:

Route::redirect('/old-about', '/about', 307);

You can coordinate with hired a Laravel developer regarding develop and manage your website with latest laravel tools.

2. Laravel 5.5 Includes TrustedProxy

On a high level, Trusted Proxy tells Laravel about proxies that can be trusted and how to map X-Forwarded-* headers from the request.

Working with Proxies

It’s commonplace for us to need to work with cloud providers like Amazon Web Services and Content Delivery Networks (CDN) like Cloudflare for full site delivery, with the application sitting behind these services instead of being exposed directly to the world. Also, your application might even be behind a chain of proxies.

When your website or application has DNS pointed at CloudFlare, for example, the HTTP requests get proxied from CloudFlare to your application.

3. Dynamic templates in Laravel Blade with View::first

When building dynamic components or pages sometimes we want to display a custom template if it exists or otherwise fall back on a default one.

For example, imagine we are building a pages module, and some pages like “About Us” or “Contact Us” will need a custom template (for example to display pictures or a contact form), while others like “Terms of services” will do fine with a default template.

Using View::first

The view()->first() method allows us to replace the following code:

if (view()->exists('custom-template')) {
return view('custom-template', $data);

return view(‘default-template’, $data);

With a simpler, more expressive version:

return view()->first(
['custom-template', 'default-template'], $data

You have to pass an array of templates as the first argument and the first method will load the first template it finds.

Of course, you can pass as many templates as you want and even use dynamic names:

return view()->first([
], $data);

Remember you can also use this feature using its facade version:

\View::first($templates, $data)

This dynamic view loading feature was added to Blade in Laravel v5.5 and is a great way of keeping your controllers simple by avoiding extra conditionals when dealing with dynamic templates.

Hire Laravel Developer from us, as we give you high quality product by utilizing all the latest tools and advanced technology. E-mail us any clock at – or Skype us: “hkinfosoft“.

To develop the custom web app using Node.js, please visit our technology page.

Content Source: