What’s New in Laravel 5.3
It’s about that time again! The release of Laravel 5.3 is imminent. That means, it’s finally time to dig in and see what’s new. And, well, there’s a lot! From directory changes, to notifications, to passports, to everything in between!
This series will be refreshed every work day, so don’t fall behind!
Important Directory Changes
Let’s start off with some of the smaller changes, and then work our way up to the big additions! To begin you’ll notice that your main directory structure is slightly different! A new routes folder at the top level? And what happened to the events, listeners, jobs, and policies folders? What’s going on!?
The Query Builder Now Returns Collections
We’re still taking it slow. What kind of series would it be if we discussed the coolest additions first? Anyways…next up, we have a small, but important change to be aware of. As of 5.3, all query builder calls will return collection objects, rather than arrays. If you think about it, this will make the general Laravel API more consistent, as relevant Eloquent calls already return collection objects.
The Global Cache Helper
In this episode, I’ll introduce you to a funky little new cache global function (gasp!) in 5.3, written by yours truly.
The JavaScript Suggestion
In Laravel 5.3, the framework makes a light suggestion on a practical JavaScript setup, using Vue. Have a look at your resources/assets/js folder to check it out. It’s important to note, however, that this is all entirely optional. If you prefer Ember or Backbone, delete the contents of your main app.js entry point, and you’re good to go! It’s only a suggestion.
Simpler Pagination
Out of the box in Laravel 5.3, pagination will still feel very similar to you. However, should you need to modify the underlying HTML, the process is now significantly easier. In fact, you’ll find that the process is very similar to how it was in Laravel 3!
Mailables
Laravel 5.3 “mailables” are thin wrappers around the traditional syntax for sending mail. I think you’ll find that they’re easier to work with, and much easier on the eyes. Let me show you the essential in this episode.
Foreach, and the Loop Object
This next addition to Laravel 5.3 is a small, but useful one. When using the foreach or forelse Blade directives, you’ll now have a new $loop object available to each iteration. This will provide useful information about the loop, including the current index, if it’s the first or last item, if there are remaining iterations for the loop, and more.
Toggle Pivot Table Records
In Laravel 5.3, you’ll find a new toggle() method on all belongsToMany relationships. This solves the issue of needing to delete a pivot table record if it exists, or adding it if it doesn’t. As an example, consider needing to toggle a user’s “like” status for a post.
Notifications: Email
Notifications in Laravel 5.3 are incredible. Create a single a notification class, and then designate one or more distribution channels to use – such as email, SMS, Slack, and more. I think you’ll really like this new component, so let’s take a few episodes to review all of its functionality. We’ll start with basic email notifications, and review the nice, fluent API for rapidly building up messages.
Notifications: Database
Let’s move on and review the database channel for sending notifications. With this approach, any notification you send will be stored in the database, at which point you can fetch them and display them for the user. In this episode, we’ll review the entire process – while also leveraging polymorphism to render each notification type within our views as cleanly as possible.
Send Slack Notifications With Laravel in Minutes
Let’s learn how to use Laravel 5.3’s Slack notification channel to notify us, the administrator, each time a payment is processed in our application. As you’ll quickly see, it’s all a cinch!
Super Simple File Uploading
Admit it: you always have to do a bit of research to remind yourself how to upload files, determine the temporary folder, guess the file extension, etc. Well now, I promise: you won’t forget. In Laravel 5.3, the UploadedFile instance offers a new store() method for rapidly saving files – even all the way to S3 (as we’ll do in this video).
Laravel Passport
Want to setup an OAuth2 server with API authentication in minutes, instead of days? Well, you’re in luck. Laravel Passport has your back! In this episode, Taylor Otwell, himself, stops by to show you the goods.
Closure-Based Commands
Closure-based commands are a useful alternative to generating full Artisan command classes. You’ll find that this approach is quite similar to how you do your routing (closures vs. controller classes). Want to pass a simple closure to handle a command? Well now you can!
Advanced Search With Laravel Scout
Laravel Scout is a driver-based solution for performing advanced, full text search on your Eloquent models. Out of the box, it comes with support for Algolia, which offers a fantastic service. In this episode, we’ll learn how to set everything up, and send a table full of records to Algolia. For the more curious among you, we’ll also, toward the end of the video, dig into the guts of Scout to figure out how everything is put together behind the scenes.
Advanced Search With Laravel Scout: Part 2
Now that you understand how to setup and import your Eloquent records, let’s figure out how to query them. You’ll find that Scout attaches a global query scope to your models, which adds a useful searchable() method. While we’re reviewing this, we’ll also take some time to review custom rankings with Algolia.
Facade Fakes
In Laravel 5.3, a number of facades provide a static fake method that can be called to replace the underlying class with a minimal fake version, for the purposes of testing. A fake is a type of test double, where you create a light, barebones implementation of a particular API or interface in order to satisfy or assist a given test.
Fluent Validation Rules
Imagine that you need to define a validation rule which specifies that the provided email address must be unique on the users table, limited to the email column, where the person’s active status is set to true, but excluding the current user’s email address. As you may know, traditionally, we must provide a comma separated list within a string for all of these parameters. It’s pretty rough! But not anymore. Now, in Laravel 5.3, you can use the useful Rule class to fluently build up these constraints.
User Reviews
Be the first to review “What’s New in Laravel 5.3”
You must be logged in to post a review.
There are no reviews yet.