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

-10.1%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
60 GB HDD
Bandwidth
Bandwidth
300 Gb
KVM-HDD HK 2048 Linux

6.26 /mo

/mo

Billed annually

-5.3%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
60 GB HDD
Bandwidth
Bandwidth
300 Gb
wKVM-HDD HK 2048 Windows

11.61 /mo

/mo

Billed annually

-21%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
8 TB
wKVM-SSD 8192 Metered Windows

65 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Epyc Cores
RAM
RAM
8 GB
Space
Space
100 GB NVMe
Bandwidth
Bandwidth
Unlimited
aiKVM-NVMe 8192 Linux

26.86 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Epyc Cores
RAM
RAM
8 GB
Space
Space
100 GB NVMe
Bandwidth
Bandwidth
Unlimited
wKVM-NVMe 8192 Windows

28.99 /mo

/mo

Billed annually

-10%

CPU
CPU
3 Xeon Cores
RAM
RAM
1 GB
Space
Space
40 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 1024 Linux

6.1 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
200 GB HDD
Bandwidth
Bandwidth
300 Gb
KVM-HDD HK 8192 Linux

20.56 /mo

/mo

Billed annually

-10%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
100 GB HDD
Bandwidth
Bandwidth
300 Gb
KVM-HDD HK 4096 Linux

12.06 /mo

/mo

Billed annually

-15.5%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
80 Mbps
DDoS Protected SSD-KVM 8192 Linux

95 /mo

/mo

Billed annually

-15.4%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
150 GB SSD
Bandwidth
Bandwidth
100 Mbps
DDoS Protected SSD-wKVM 16384 Windows

130 /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.