Laravel 11.31: A Powerful New Release with Dynamic Builders and More

Laravel 11.31 brings exciting new features, including dynamic builders for mailers, databases, and caches, improved cache token management, and enhanced control over middleware priority. These advancements empower developers to build more flexible and efficient Laravel applications.

Laravel 11.31 introduces several new features and improvements to enhance developer experience. Here’s a breakdown of the key additions:

Cache Management:

  • Cache Token Repository: This new feature allows storing password reset tokens in the cache, offering a more ephemeral solution compared to the database. (Contributed by Andrew Brown)

Dynamic Builders:

  • Mail::build(): Developers can now dynamically build and send mailers based on configurations, eliminating the need for hard-coded configurations. (Contributed by Steve Bauman)
  • DB::build(): Similar to Mail::build(), this method lets you create new database connections on-demand, even if they aren’t defined in your configuration file. (Contributed by Steve Bauman)
  • Cache::build(): Build cache repositories dynamically using this method, providing flexibility for on-demand cache management. (Contributed by Steve Bauman)

Improved Control:

  • Batch and Chain onQueue() with Backed Enums: This update allows using backed enums with the onQueue() method for better control over job queues. (Contributed by Philip Iezzi)
  • Application::removeDeferredServices(): This method simplifies removing deferred services from the application container. (Contributed by Ollie Read)
  • Middleware Priority Control: You can now manage middleware priority within the application builder, allowing insertion before or after specific middleware. (Contributed by Ollie Read)
  • URL::forceHttps(): Enforce HTTPS scheme for URLs by using this convenient method. It accepts a boolean value for easy configuration based on environment. (Contributed by Dasun Tharanga)

Other Enhancements:

  • Improved test coverage and bug fixes across various components.
  • Ability to dynamically pop items from stackable context items.
  • Support for creating models with the HasFactory trait using the make:model command with the --all option.
  • Ensure datetime cache durations account for script execution time.
  • Various bug fixes related to collections, schema foreign ID support, and more.

For a complete list of changes, refer to the official Laravel changelog:

I hope this summary provides a clear understanding of the key features introduced in Laravel 11.31!