What's new in Laravel 8?

What's new in Laravel 8?

A roundup of the new features in Laravel 8, as announced by Taylor Otwell at Laracon 2020, including Laravel JetStream.

As I'm sure you heard if you follow along with the Laravel community, the latest Laracon event was held on Wednesday, which was hosted online instead of the usual summer conference in the US. There were 15 fantastic speakers, but there was one that everybody was waiting for.

Taylor Otwell take to the (virtual) stage to announce the features coming to the next release of the framework, Laravel 8. He started out with some smaller "quality of life" changes, before really taking it up a level and introducing a raft of improvements and new features coming to Laravel 8 when it's released, on September 8th 2020.

Let's dive straight in and take a look at what was announced.

New landing page

The page that gets displayed when you hit the homepage on a fresh install has had a facelift and is now built with TailwindCSS and comes in light / dark versions. It has links to various SaaS products from Laravel, as well as community sites. There is also a link to the new Laravel shop if you want to get your hands on some merch.

Default app/models directory

Laravel 8 will now ship with an app/models directory, rather than leaving model class in the root app directory as in previous versions of Laravel. According to a poll run by Taylor, over 80% of developers were creating an app/models directory themselves anyway.

If you use any of the artisan generator commands that create a model class for you, such as php artisan make:model - it will of course create you a new model inside the new app/models directory. However, if you prefer to keep your models in your app directory and delete the new models directory, the generator commands will respect that and create the model classes in your appdirectory.

Controllers namespace prefix removed

In previous versions of Laravel, there was a property in the RouteServiceProvider.php called $namespace that was used to prefix the namespace of your controllers automatically (applying App\Http\Controllers). If you were using the callable syntax in your web.php routes file, Laravel may have double prefixed your namespaces. This property has been removed in Laravel 8, so you can import your controller classes in your routes file without issue.

Route caching improvements

Hopefully you were already using route caching in your application (running php artisan route:cache generates a PHP file with an array containing all of your routes, which Laravel then uses for routing as it's faster than having to parse your routes file(s) on every request). However, up until now, if you had any closures in your routes, or even if a package registered a route with a closure, that would have caused the route caching to fail.

Not anymore with Laravel 8 - it now supports route caching for closure based routes! Now you have no excuses not be using route caching.

Blade component attributes

If you extended a Blade component (e.g. having a component called DangerButton, that extended another component called Button) in Laravel 7, the child button wouldn't have had the $attributes passed down to it. That has changed in Laravel 8 - all child components will the $attributes available, making it easier to build extended components.

Cleaner syntax for closure based event listeners

In previous Laravel versions, when registering a closure based even listener, you had to first define the event class, then register the closure, and probably type hint the event class for the closure e.g.:

Event::listen(OrderShipped::class, function(OrderShipped $event) { 
    // Do something

In Laravel 8, you'll be able to skip the first definition of the event class as the framework will be able to infer it from the type hinted argument - e.g.:

Event::listen(function(OrderShipped $event) { 
    // Do something

Queueable anonymous event listeners

In Laravel 8, you will be able to send a closure based job to the queue from your model event callbacks e.g.:

class User extends Model {

    protected static function booting() 
        static::created(queueable(function(User $user) {
           // Do something in the background


In previous Laravel versions, it was not possible to do this unless you created an event class and event listener, using the ShouldQueue trait. This new feature makes it quicker and actually introduces the first namespaced function into the Laravel framework, Illuminate\Events\queueable.

laravel php web development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

PHP Web Application Development Company

As a top **PHP Web Application Development Company in USA**[https://www.dataeximit.com/php-development-services/](https://www.dataeximit.com/php-development-services/ "https://www.dataeximit.com/php-development-services/"), we at Data EximIT have...

PHP Website Development

Skenix Infotech is a leading PHP Web Development Company that helps companies get results with industry best practices. Get affordable PHP Development Services.

Laravel Development Company

Skenix Infotech is a top Laravel Website Development Company with Expert Laravel Developers that provides robust Laravel Development Services at fair costs.

Hire Dedicated PHP Developer

Looking to hire affordable yet experienced PHP developers? **[Hire Dedicated PHP Developer](https://hourlydeveloper.io/hire-dedicated-php-developer/ "Hire Dedicated PHP Developer")**, who can convert your idea to reality, within the stipulated...

PHP Website Development

Skenix Infotech is a leading PHP Web Development Company that helps companies get results with industry best practices. Get affordable PHP Development Services.