Skip to content
  • Services
  • About
  • Partners
  • Work
  • Insights
  • Careers
  • Contact
  • Services
  • About
  • Partners
  • Work
  • Insights
  • Careers
  • Contact
September 15, 2020

The 15 Best New Features in Laravel 8

Agile Software Development, Laravel

Laravel 8, the most recent version of the Laravel framework, was released on September 8. Laravel 8 comes with exciting new features and a guide to upgrade. Laravel creator Taylor Otwell announced some of those new features in his Laracon presentation. This post contains a summary of some of the new capabilities announced. Let’s take a look at some of those great new features!

1. app/Models Directory

The artisan:make model command will create the model in the app/Models directory. This feature was decided after Taylor asked people on Twitter how they feel about this.

To those in the "app/Models" camp. What do you do when you have 1 class that isn't a model – it's just a regular class? Since you have set a precedent that no files can live in "app" directory, do you create some "Misc" folder? "Libraries"? 😬

— Taylor Otwell 🛸 (@taylorotwell) June 30, 2020

Spicy Monday poll… don't respond with some "I follow DDD and put them in contextual directories" thing either 💋

— Taylor Otwell 🛸 (@taylorotwell) June 29, 2020

If you don’t like that, it’s possible to delete the app/Models directory and artisan will create the model file in the app/ folder. It’s cool that Laravel is built with so much input from the community!

2. New Landing Page

Laravel 8 comes with a new landing page for a brand new install. It is now redesigned and It is built using TailwindCSS, includes light and dark-mode capabilities, and by default extends links to SaaS products and community sites.

3. Controllers Routing Namespacing

No more double prefix issues! In previous versions of Laravel, the RouteServiceProvider had an attribute called namespace that was used to prefix the controllers in the routes files. That created a problem when you were trying to use a callable syntax on your controllers, causing Laravel to mistakenly double prefix it for you. This attribute was removed and now you can import and use it without the issue.

It can also be used for single action controllers that have the __invoke method.

Controllers Routing Namespacing

4. Route Caching

Laravel uses route caching to compile your routes in a PHP array that is more efficient to deal with. In Laravel 8, it’s possible to use this feature even if you have closures as actions to your routes. This should extend the usage of route caching for improved performance.

Route Caching

5. Attributes on Extended Blade Components

In Laravel 7 the child components didn’t have access to the $attributes passed to it. In Laravel 8 these components were enhanced and it is now possible to merge nested component attributes. This makes it easier to create extended components.

Attributes on Extended Blade Components

6. Better Syntax for Event Listening

In the previous versions of Laravel, when creating a closure based event listener there was much repetition and a cumbersome syntax.

Better Syntax for Event Listening 1 of 2

In Laravel 8 it’s simpler and cleaner:

Better Syntax for Event Listening 2 of 2

7. Queueable Anonymous Event Listeners

In Laravel 8 it is possible to create queueable closure from anywhere in the code. This will create a queue of anonymous event listeners that will get executed in the background. This feature makes it easier to do this, while in previous versions of Laravel you would need to use an event class and an event listener (using the ShouldQueue trait).

Queueable Anonymous Event Listeners

8. Maintenance Mode

Maintenance Mode 1 of 3

This is especially useful when you need to do some maintenance on your application and you want to take it down for your users but still let your developers investigate bugs. This will create a secret cookie that will be granted to whoever hits the correct endpoint, allowing it to use the application while in maintenance mode.

Maintenance Mode 2 of 3

Pre-rendering an error view is a safe way for not exposing errors to your end user when your application is down (during a new deployment, for example). The Laravel 8 framework guarantees that your predefined error page will be displayed before everything else from the application.

Maintenance Mode 3 of 3

This combines the new features and will make the application only display a single predefined route, while still allowing for the people who have the secret to test and debug. This can be very useful when launching a new app.

9. Closure Dispatch “Catch”

Closure Dispatch "Catch"

Laravel has a pretty robust queue system that accepts a closure queue that will get serialized and executed in the background. Now we have a way to handle failures in case your job fails.

10. Exponential Backoff Strategy

This is an algorithm that decreases the rate of your job in order to gradually find an acceptable rate.

Exponential Backoff Strategy

Now Laravel has this capability too, which is handy for jobs that deal with external APIs, where you wouldn’t want to try again on the same amount of time. It can also be used to dynamically generate the return array, setting different times to wait before retrying.

11. Job Batching

Job Batching

Modeled after the Sidekiq and Ruby library, job batching makes it easy to handle many jobs at the same time concurrently. It’s also easy to be notified when all jobs are complete, or when there’s any error on it’s execution. You can see more details on the PR that added this functionality.

12. Rate Limiting

Rate limiting provides a new and more convenient way of limiting the use of your routes.

Rate Limiting

13. Schema Dumping

Schema Dumping

Schema dumping is a way to squash migrations to a single file. It generates a schema file that has the whole schema for your database in a SQL form. This is used during development, useful for integrating new developers on your project that already has a large number of migrations. It supports MySQL, Postgres, SQLite.

14. Model Factories

Model factories are class based factories that add a lot of new features to Laravel 8. For each model there’s also a factory class, where there is a definition method that says which attributes it will generate for that model. Your models make use of that factory through the Factory trait.

Factories are rewritten for Laravel 8 to be class based. 🦩 pic.twitter.com/2ODeIfktsC

— Laravel News (@laravelnews) August 26, 2020

15. Laravel Jetstream

Laravel Jetstream is a brand new scaffolding for Laravel released as an open-source package. It builds an application using TailwindCSS and TailwindUI, includes login, registration, two-factor authentication, session management. It offers two versions for handling frontend: Livewire (TALL Stack) or InertiaJS (VueJS)

Laravel Jetstream

References

  • Laravel 8 – A rundown of new features
  • What’s new in Laravel 8?
  • Laravel 8 Goodies – Part 1
  • Features and Changes Coming to Laravel 8’s Queue System
  • Laravel 8 Upgrade Guide
  • Time traveling is coming to Laravel 8
  • Reddit – What’s new on Laravel 8

This post was published under the Laravel Community of Experts. Communities of Experts are specialized groups at Modus that consolidate knowledge, document standards, reduce delivery times for clients, and open up growth opportunities for team members. Learn more about the Modus Community of Experts program in the article Building a Community of Experts.

Posted in Agile Software Development, Laravel
Share this

Guido Percú

Guido Percú is a Full Stack Engineer at Modus Create, where he creates software projects using Python, PHP and AWS solutions. Born and raised in Brazil, he lives in Rio de Janeiro with his wife. When he is not coding, he enjoys reading books, learning about stock markets and practicing Karate.
Follow

Related Posts

  • Modus Create Community of Experts Header Image
    The Challenges of Building a Community of Experts

    While Communities of Experts improve outcomes for our clients and aid career growth for our…

  • Comparing AdonisJS to Laravel
    Comparing AdonisJS to Laravel

    Over the past two years I have been involved in a project that was built…

Subscribe to the Modus Newsletter

Receive the latest blog articles and insights every month from the Modus team.

Let's Chat

If forms aren’t your thing, you can always call us (+1-855-721-7223).

Modus-Logo-Primary-White.svg
  • Services
  • About
    • Newsroom
  • Partners
  • Work
  • Insights
    • Blog
    • Modus Labs
  • Careers
Virginia (US)

12100 Sunset Hills Road
Suite 150
Reston, Virginia, 20190
Tel: +1-855-721-7223

California (US)
12130 Millennium Dr

Los Angeles, CA 90094

Missouri (US)
609 E High St

Jefferson City, MO 65101

Romania

Str. Mihai Veliciu, no. 17
Cluj-Napoca, Romania
Tel: +40-0786-887-444

Costa Rica

2nd Floor, Plaza Koros, Av 3
San José, Santa Ana, Costa Rica

© 2021 Modus. All Rights Reserved.

Privacy Policy | Accessibility Statement | Sitemap

This website uses cookies.
These cookies are used to collect information about how you interact with our website and allow us to remember you. We use this information in order to improve and customize your browsing experience, and for analytics and metrics about our visitors both on this website and other media. To find out more about the cookies we use, see our Privacy Policy.

Accept
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled

Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.

Non-necessary

Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.

SAVE & ACCEPT
Scroll To Top