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.

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
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

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
LaraJobs logo

LaraJobs

The official Laravel job board

LaraJobs
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate logo

Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate

Build your SaaS application in hours. Out-of-the-box multi-tenancy and seamless Stripe integration. Supports subscriptions and one-time purchases, allowing you to focus on building and creating without repetitive setup tasks.

Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate
Rector logo

Rector

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

Rector
MongoDB logo

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB

The latest

View all →
Asymmetric Property Visibility in PHP 8.4 image

Asymmetric Property Visibility in PHP 8.4

Read article
Access Laravel Pulse Data as a JSON API image

Access Laravel Pulse Data as a JSON API

Read article
Laravel Forge adds Statamic Integration image

Laravel Forge adds Statamic Integration

Read article
Transform Data into Type-safe DTOs with this PHP Package image

Transform Data into Type-safe DTOs with this PHP Package

Read article
PHPxWorld - The resurgence of PHP meet-ups with Chris Morrell image

PHPxWorld - The resurgence of PHP meet-ups with Chris Morrell

Read article
Herd Executable Support and Pest 3 Mutation Testing in PhpStorm 2024.3 image

Herd Executable Support and Pest 3 Mutation Testing in PhpStorm 2024.3

Read article