Laravel 5.6 is Live, Here’s What’s New!

Published on by

Laravel 5.6 is Live, Here’s What’s New! image

The Laravel 5.6 release is now officially available as the next major version of the Laravel framework! This release has many new features, and we’ve highlighted the more prominent features here. For a full list of all changes visit the changelog (GitHub).

Logging Improvements

The biggest feature in Laravel 5.6 release is the logging improvements. For starters, v5.6 logging configuration moves from the config/app.php file to the new config/logging.php file.

You configure “stacks” that can send log messages to multiple handlers. For example, you might send all debug messages to a system log and send error logs to slack.

Read more about configuring and customizing logs by visiting the logging documentation.

Single Server Task Scheduling

If you have a task scheduler running on multiple servers, the task will run on each server. You can indicate that a task should only run on one of those servers with the onOneServer() method:

$schedule->command('report:generate')
->fridays()
->at('17:00')
->onOneServer();

Note: you must use the memcached or redis cache driver as the default application cache driver to take advantage of single server task scheduling in the Laravel 5.6 release.

Dynamic Rate Limiting

Laravel 5.6 introduces dynamic rate limiting that gives you more flexibility and makes it possible to easily rate limit on a per-user basis:

Route::middleware('auth:api', 'throttle:rate_limit,1')
->group(function () {
Route::get('/user', function () {
//
});
});

In the above example, the rate_limit is an attribute of the App\User model to determine the number of requests allowed in the given time limit.

Broadcast Channel Classes

You can now use channel classes in your routes/channels.php file instead of using closures.

To generate a new channel class, Laravel 5.6 provides a new make:channel command:

php artisan make:channel OrderChannel

You register your channel in the routes/channels.php file like so:

use App\Broadcasting\OrderChannel;
 
Broadcast::channel('order.{order}', OrderChannel::class);

API Controller Generation

You can now generate a resource controller for APIs that will exclude the unnecessary create and edit actions, which only apply to resource controllers returning HTML. To generate a resource controller, use the --api flag:

php artisan make:controller API/PhotoController --api

Eloquent Date Casting

You can individually customize the format of Eloquent date and datetime casting:

protected $casts = [
'birthday' => 'date:Y-m-d',
'joined_at' => 'datetime:Y-m-d H:00',
];

This format is used on model serialization to an array or JSON data.

Blade Component Aliases

You can now alias blade components for more convenient access. For example, if you store a component at resources/views/components/alert.blade.php you can use the component() method to alias it to a shorter name:

Blade::component('components.alert', 'alert');

You can then render it with the defined alias:

@component('alert')
<p>This is an alert component</p>
@endcomponent

Argon2 Password Hashing

Laravel 5.6 supports a new password hashing algorithm for PHP 7.2+. You can control which hashing driver is used by default in the new config/hashing.php configuration file.

You can learn more in our article about Laravel 5.6 support for the Argon2i hashing algorithm.

UUID Methods

Two new methods are now available in the Illuminate\Support\Str class for generating Universal Unique Identifiers (UUID):

// The methods return a Ramsey\Uuid\Uuid object
 
return (string) Str::uuid();
 
return (string) Str::orderedUuid();

The orderedUuid() method will generate a timestamp first UUID for easier and more efficient database indexing.

Collision

We recently wrote about Collision coming to Laravel 5.6 as a dev dependency, providing beautiful error reporting in the console:

Bootstrap 4

All of the frontend scaffolding and example Vue component now use Bootstrap 4. We have covered Bootstrap 4 while in beta, and even created a Bootstrap 4 Laravel preset. It’s great to see Bootstrap 4 stable shipping with Laravel 5.6!

Learning More About Laravel 5.6

To upgrade your Laravel installation to v5.6, reference the upgrade guide. Laravel strives to make updating your application between major releases as short as possible. The upgrade from 5.5 to 5.6 is estimated to take between 10-30 minutes. Obviously, your mileage will vary based on your application.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Filed in:
Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
Join the Mastering Laravel community logo

Join the Mastering Laravel community

Connect with experienced developers in a friendly, noise-free environment. Get insights, share ideas, and find support for your coding challenges. Join us today and elevate your Laravel skills!

Join the Mastering Laravel community
Laravel Idea for PhpStorm logo

Laravel Idea for PhpStorm

Ultimate PhpStorm plugin for Laravel developers, delivering lightning-fast code completion, intelligent navigation, and powerful generation tools to supercharge productivity.

Laravel Idea for PhpStorm
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
Rector logo

Rector

Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies

Rector
LaraJobs logo

LaraJobs

The official Laravel job board

LaraJobs
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
MongoDB logo

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB

The latest

View all →
Handling Request Data Presence in Laravel image

Handling Request Data Presence in Laravel

Read article
First Factor One-Time Passwords for Laravel with OTPZ image

First Factor One-Time Passwords for Laravel with OTPZ

Read article
Managing Request Host Information in Laravel image

Managing Request Host Information in Laravel

Read article
Tim Leland: URL Shorteners, browser extensions, and more image

Tim Leland: URL Shorteners, browser extensions, and more

Read article
HTTP Method Verification in Laravel image

HTTP Method Verification in Laravel

Read article
Packistry is a Self-hosted Composer Repository Made with Laravel image

Packistry is a Self-hosted Composer Repository Made with Laravel

Read article