What We Know So Far About Laravel 5.3
comment 0

What We Know So Far About Laravel 5.3

You may be familiar with Laravel, the free open-source PHP framework built specifically for web artisans. Taylor Otwell, the creator of Laravel was not satisfied with the existing PHP frameworks at the time (CodeIgniter, Yii, Zend and Symfony) and because of this, decided to build his own. It has been 5 years since its introduction to the web and now its latest version is arriving soon, Laravel 5.3.

This new version of Laravel is exciting to developers using it because it will come with an assortment of new features along with some improvements to its framework. What we know so far was from Laracon 2016, where the creator himself presented to the world, what would be coming for Laravel 5.3.

So here’s a list of features and improvements that we know so far.

 

New Features

1) Laravel Scout

Laravel Scout is a driver based full-text search for Eloquent. Scout works by implementing a “Searchable” trait with your existing models.

Post::search('Alice')->get();

2) Laravel Mailable

Laravel Mailable is a new Mail class for sending emails in an expressive way:

Mail::to('[email protected]')->send(new OrderComplete);

3) Laravel Notifications

With Laravel Notifications, a responsive transactional email template is now being used when a notifications is sent. In your notification class all that is needed to send a message is coded like the following:

$this->line('Thank you for joining')
   ->action('Button Text', 'http://url.com')
   ->line('If you have any questions please hit reply')
   ->success()

4) Laravel Passport

Laravel Passport is an optional package that is a full oAuth 2 server ready to go.
You can set your scopes, Vue.js components for token generation, revoking tokens, and more.

All these new feature will fully documented when the 5.3 launch.

 

Improvements

1) Blade’s foreach $loop

5.3 introduces a $loop variable inside a foreach loop. This variable can help us easy manage indexes, increments in loops etc.

<ul>
   @foreach ($countries as $country)
      @if ($loop->count)
         @if ($loop->first)
            <li class="list-item list-item--header">{{ $country->name }}</li>
         @elseif ($loop->last)
            <li class="list-item list-item--footer">{{ $country->name }}</li>
         @else
            <li class="list-item">{{ $country->name }}</li>
         @endif
      @endif
   @endforeach
</ul>

2) Multiple Migration Paths

In 5.3 you can define a migration path. before this, you need to copy all the migrations into migrations folder. To let Laravel know about others migration folder just do.

$this->loadMigrationsFrom('path/to/migrations/folder');

3) Query Builder Returns a Collection

Before this, the query builder was an array. An array will need to be looped through first before we begin performing an operation. Just like ORM, you won’t need it anymore when you use ‘collection’. In fact, you can now do this instead :

$result = DB::table('posts')->get();

if ($result->first()) { } 
if (!$result->isEmpty()) { }
if ($result->count()) { }
if (count($result)) { }

4) Migration Rollback in Steps

Before this if you do rollback, it will roll back entire migrations of our own. The step migration procedure just got a whole lot safer.

php artisan migrate:rollback --step=1

5) Ability to Customize Simple Pagination

The ability to customize simple navigation with views is making a return with Laravel 5.3 probably due to demands of its use.

<ul class="pagination">
   @if ($paginator->onFirstPage())
      <li class="disabled"><span>«</span></li>
   @else
      <li>
         <a href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a>
      </li>
   @endif
</ul>

Conclusion

For those who are unfamiliar with the framework, many other PHP developers have found great success using Laravel. This is thanks to its extendable quick and functional core, easy integration with third-party libraries, and a growing developer community.

At the time of this post, Laravel 5.3 is not officially released yet but it doesn’t stop us from hyping about its new features and improvements. For Laravel veterans, this is something for you guys to be excited about. For PHP developers who aren’t using this framework, why not give it a try?

Filed under: Resources

About the Author

Posted by

Tony is a web analyst and developer for Stampede. He is highly inquisitive, a quick learner and always ready to take on new challenges while trailblazing through the tricky forests of web programming. A family man - in his free time, he spends time with his lovely wife and daughter.

Leave a Reply