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

-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

-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

-10%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
Unlimited
MT5 KVM 4096 Linux

19.99 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
Unlimited
KVM-SSD 8192 Linux

25.85 /mo

/mo

Billed annually

-4.7%

CPU
CPU
3 Xeon Cores
RAM
RAM
1 GB
Space
Space
40 GB HDD
Bandwidth
Bandwidth
300 Gb
wKVM-HDD HK 1024 Windows

10.35 /mo

/mo

Billed annually

-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.71 /mo

/mo

Billed annually

-10%

CPU
CPU
2 Epyc Cores
RAM
RAM
1 GB
Space
Space
10 GB NVMe
Bandwidth
Bandwidth
Unlimited
KVM-NVMe 1024 Linux

7.1 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
200 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 8192 Linux

25.25 /mo

/mo

Billed annually

-20.6%

CPU
CPU
6 Xeon Cores
RAM
RAM
8GB
Space
Space
100GB SSD
Bandwidth
Bandwidth
500GB
KVM-SSD 8192 HK Linux

59 /mo

/mo

Billed annually

-10%

CPU
CPU
2 Xeon Cores
RAM
RAM
512 MB
Space
Space
10 GB SSD
Bandwidth
Bandwidth
Unlimited
KVM-SSD 512 Linux

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