What’s New in Laravel 11.34

watch 1m, 18s
views 2

14:30, 02.12.2024

Laravel is one of the most popular frameworks for developing web applications in PHP. In Laravel 11.34, the developers introduced important changes to improve the framework's usability, such as the ability to write ordinal numbers in words, conditional traits in routes, the simplified syntax for fake HTTP responses, the Request::fluent() method, and much more.

Major Changes in Laravel 11.34

Writing Ordinal Numbers in Words

The spellOrdinal() method has been added to the Number helper, which allows you to write ordinal numbers in words:

'The ' . Number::spellOrdinal(40) . ' president of the United States is Ronald Reagan';

Conditional Traits to Routes

Added conditional traits to the Route class, allowing you to add conditional logic when defining routes:

Route::middleware('shop') ->domain('{shop}.domain.com') ->when(App::isProduction(), function ($route) { $route->whereIn('shop', app(ShopService::class)->getShopSlugs()); });

Simplified Fake HTTP Responses

Jason McCreary added a simplified syntax for fake HTTP responses, with the ability to use strings for the response body and integers for the status code:

Previously:

// Http::fake([ 'google.com' => Http::response('Hello World'), 'github.com' => Http::response(['foo' => 'bar']), 'forge.laravel.com' => Http::response(status: 204), ]);

Now:

// Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' => 204, ]);

Added Request::fluent() method

Added a fluent() method for the HTTP Request class to allow convenient passing of input data:

/* @var Illuminate\Http\Request $request /$data = $request->fluent();
$data->title; $data->body; //

Code Compatibility with PHP 8.4

Added code compatibility with PHP 8.4 for Laravel 10.x and 11.x.

Share

Was this article helpful to you?

VPS popular offers

-8.8%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
400 GB HDD
Bandwidth
Bandwidth
300 Gb
wKVM-HDD HK 16384 Windows

45.01 /mo

/mo

Billed annually

-10%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
60 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 2048 Linux

7.7 /mo

/mo

Billed annually

-8.1%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
200 GB HDD
Bandwidth
Bandwidth
Unlimited
wKVM-HDD 8192 Windows

31.25 /mo

/mo

Billed annually

-22.2%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
50 GB SSD
Bandwidth
Bandwidth
300 GB
KVM-SSD 4096 HK Linux

33 /mo

/mo

Billed annually

-10%

CPU
CPU
4 Epyc Cores
RAM
RAM
4 GB
Space
Space
50 GB NVMe
Bandwidth
Bandwidth
Unlimited
aiKVM-NVMe 4096 Linux

16.55 /mo

/mo

Billed annually

-9.5%

CPU
CPU
8 Epyc Cores
RAM
RAM
32 GB
Space
Space
200 GB NVMe
Bandwidth
Bandwidth
Unlimited
wKVM-NVMe 32768 Windows

74.49 /mo

/mo

Billed annually

-10%

CPU
CPU
10 Epyc Cores
RAM
RAM
64GB
Space
Space
400 GB NVMe
Bandwidth
Bandwidth
Unlimited
Keitaro KVM 65536
OS
CentOS
Software
Software
Keitaro

149.04 /mo

/mo

Billed annually

-29.4%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
30 GB SSD
Bandwidth
Bandwidth
2 TB
KVM-SSD 2048 Metered Linux

17 /mo

/mo

Billed annually

-9.6%

CPU
CPU
8 Xeon Cores
RAM
RAM
32 GB
Space
Space
200 GB SSD
Bandwidth
Bandwidth
12 TB
wKVM-SSD 32768 Metered Windows

156 /mo

/mo

Billed annually

-10%

CPU
CPU
3 Epyc Cores
RAM
RAM
2 GB
Space
Space
20 GB NVMe
Bandwidth
Bandwidth
Unlimited
aiKVM-NVMe 2048 Linux

8.86 /mo

/mo

Billed annually

Other articles on this topic

cookie

Accept cookies & privacy policy?

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the HostZealot website.