Laravel 9.10 Released

Published on by

Laravel 9.10 Released image

The Laravel team released 9.10 with a findOr() Eloquent method, a new command assertion, retrieve input as a Stringable instance, and more:

Before Refreshing Database Function

Rok Sprogar contributed a beforeRefreshingDatabase to the RefreshDatabase trait. This allows you to run code before the database starts refreshing:

class DataExportTest extends TestCase
{
use RefreshDatabase;
 
protected $seed = true;
 
protected function beforeRefreshingDatabase()
{
$this->artisan('db:wipe --database another-database-connection');
}
 
// ...
}

Does Not Expect Output Command Assertion

Markus Hebenstreit contributed a doesntExpectOutputToContain Command assertion method which is self-explanitory:

Artisan::command('contains', function () {
$this->line('My name is Taylor Otwell');
});
 
$this->artisan('contains')
->doesntExpectOutputToContain('Taylor Otwell');

Eloquent "findOr" Method

Jess Archer contributed a findOr() method to the Eloquent builder and relations. This method matches the existing firstOr() methods:

User::findOr(1, fn () => throw new RuntimeException);
User::findOr(1, fn () => abort(403));
User::findOr(1, fn () => 'return something');
User::findOr(1, ['columns'], fn () => '...');
 
// Also works with relations
$user->posts()->findOr(1, fn () => '...');

Customizable Compiled Extension

Taylor Otwell contributed a configurable compiled view extension that is customizable via the view configuration when passed into the blade compiler:

new BladeCompiler(
$app['files'],
$app['config']['view.compiled'],
$app['config']->get('view.relative_hash', false) ? $app->basePath() : '',
$app['config']->get('view.cache', true),
$app['config']->get('view.compiled_extension', 'php'),
);

Support for "IS" and "IS NOT" PostgreSQL Operators

Markus Koch contributed support for is and is not operators when using PostgreSQL. See Pull Request #42123 for details.

Retrieve Input from the Request as Stringable

Cameron Wilby and Taylor Otwell contributed the ability to retreive input from the request as a Stringable instance:

$name = $request->string('name');
// or
$name = $request->str('name');

Append and Prepend Jobs to Existing Chain

Jan-Oliver Pantel contributed prependToChain() and appendToChain methods to append and prepend jobs:

The use case for that is whenever a job within a chain want's [sic] to enqueue jobs onto it's own chain without the need to create a new one and wait for successful execution of the "child chain".

This is technically already possible since all the needed properties and methods are public. However having formalized functions for that makes for a better DX.

See Pull Request #42138 for details.

Release Notes

You can see the complete list of new features and updates below and the diff between 9.9.0 and 9.10.0 on GitHub. The following release notes are directly from the changelog:

v9.10.0

Added

  • Add the ability to use alias when performing upsert via MySQL (#42053)
  • Illuminate/Routing/Router::middlewareGroup() will support array of the middlewares (#42004, e6b84fb)
  • Added Missing AsCommand attribute on schedule:list (#42069)
  • Add the beforeRefreshingDatabase function to the Testing/RefreshDatabase trait (#42073)
  • Added doesntExpectOutputToContain assertion method (#42096)
  • Added a findOr method to Eloquent (#42092)
  • Allow extension in Illuminate/View/Compilers/Compiler.php (68e41fd)
  • Support 'IS' and 'IS NOT' PostgreSQL operators (#42123)
  • Added str and string methods to Illuminate/Http/Concerns/InteractsWithInput (c9d34b7)
  • Added methods to append and prepend jobs to existing chain (#42138)

Fixes

  • Make it so non-existent jobs run down the failed path instead of crashing (#42079)
  • Fix schedule:work command Artisan binary name (#42083)
  • Fix TrimStrings middleware with non-UTF8 characters (#42065)
  • Copy locale and defaultLocale from original request in Request::createFrom() (#42080)
  • Fix ViewErrorBag for JSON session serialization (#42090)
  • Fix array keys from cached routes in CompiledRouteCollection::getRoutesByMethod() (#42078)
  • Fix json_last_error issue with JsonResponse::setData (#42125)
  • Fix bug in BelongsToMany where non-related rows are returned (#42087)
  • Fix HasAttributes::mutateAttributeForArray when accessing non-cached attribute (#42130)

Changed

  • Make password rule errors translatable (#42060)
  • Redesign of the event:list Command. (#42068)
  • Changed event:list command (#42084)
  • Throw LostDbConnectionException instead of LogicException (#42102)
  • Throw deadlock exception (#42129)
  • Support Arr::forget() for nested ArrayAccess objects (#42142)
  • Allow Illuminate/Collections/Enumerable::jsonSerialize() to return other types (#42133)
  • Update schedule:list colouring output (#42153)
Paul Redmond photo

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

Cube

Laravel Newsletter

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

image
Laravel Forge

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

Visit Laravel Forge
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
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
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
LoadForge logo

LoadForge

Easy, affordable load testing and stress tests for websites, APIs and databases.

LoadForge
Paragraph logo

Paragraph

Manage your Laravel app as if it was a CMS – edit any text on any page or in any email without touching Blade or language files.

Paragraph
Lucky Media logo

Lucky Media

Bespoke software solutions built for your business. We ♥ Laravel

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
DocuWriter.ai logo

DocuWriter.ai

Save hours of manually writing Code Documentation, Comments & DocBlocks, Test suites and Refactoring.

DocuWriter.ai
Rector logo

Rector

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

Rector

The latest

View all →
Non-backed Enums in Database Queries and a withSchedule() bootstrap method in Laravel 11.1 image

Non-backed Enums in Database Queries and a withSchedule() bootstrap method in Laravel 11.1

Read article
Laravel Pint --bail Flag image

Laravel Pint --bail Flag

Read article
Laravel Herd for Windows is now released! image

Laravel Herd for Windows is now released!

Read article
The Laravel Worldwide Meetup is Today image

The Laravel Worldwide Meetup is Today

Read article
Cache Routes with Cloudflare in Laravel image

Cache Routes with Cloudflare in Laravel

Read article
Learn how to manage timezones in your Laravel Apps image

Learn how to manage timezones in your Laravel Apps

Read article