Laravel 7.12 Released

News

May 20th, 2020

Laravel 7.12 Released

The Laravel team released v7.12.0 with a new TrustHosts middleware, along with the latest updates to the 7.x branch.

TrustHosts Middleware

Taylor Otwell contributed a new TrustHosts middleware, configuring a whitelist of trusted hosts in the Illuminate request object. By default, the HTTP Foundation configuration is an empty array, so this middleware will help you lock down the hosts (via regex) your application will recognize.

The setting out of the box for Laravel is all subdomains on the configured app.url value. As of Laravel 7, this middleware is opt-in, so you can either uncomment it in a new app or add the following once you upgrade to v7.12:

protected $middleware = [
\App\Http\Middleware\TrustHosts::class,
];

The bulk of the logic comes from the base middleware class in the framework, and then the Laravel app has an accompanying TrustHosts middleware that extends the framework. You are free to customize and override the base middleware host whitelist logic.

Skip Middleware in Resource Routes

Sébastien Nikolaou contributed the ability to skip middleware from resource routes. Here’s an example from Pull Request #32891:

Route::middleware(['auth', 'verified'])->group(function () {
Route::resource('photo', 'PhotosController')->withoutMiddleware('verified');
});

Release Notes

You can see the full list of new features and updates below and the diff between 7.11.0 and 7.12.0 on GitHub.

Note: the official release notes were not available at the time of writing, you can always see the latest in CHANGELOG-7x.

v7.12.0

Added

  • Added Illuminate\Http\Middleware\TrustHosts (9229264)
  • Ability to skip middleware from resource routes (#32891)

Fixed

  • Fixed Queued Mail MessageSent Listener With Attachments (#32795)
  • Added error clearing before sending in Illuminate\Mail\Mailer::sendSwiftMessage() (#32799)
  • Avoid foundation function call in the auth component (#32805)
  • Fixed inferred table reference for Illuminate\Database\Schema\ForeignIdColumnDefinition::constrained() (#32847)
  • Fixed wrong component generation (73060db)
  • Fixed bug with request rebind and url defaults in Illuminate\Routing\UrlGenerator (6ad92bf)
  • Fixed Illuminate\Cache\ArrayStore::increment() bug that changes expiration to forever (#32875)

Changed

  • Dont cache non objects in Illuminate/Database/Eloquent/Concerns/HasAttributes::getClassCastableAttributeValue() (894fe22)
  • Added explicit symfony/polyfill-php73 dependency (5796b1e)
  • Set Cache\FileStore file permissions only once (#32845, 11c533b)
  • Added alias as key of package’s view components (#32863)

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.