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.1%

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

31.9 /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

CPU
CPU
6 Epyc Cores
RAM
RAM
16 GB
Space
Space
150 GB NVMe
Bandwidth
Bandwidth
Unlimited
Keitaro KVM 16384
OS
CentOS
Software
Software
Keitaro
/mo

Billed monthly

-7.1%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
100 GB HDD
Bandwidth
Bandwidth
Unlimited
wKVM-HDD 4096 Windows

21 /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

-15.6%

CPU
CPU
3 Xeon Cores
RAM
RAM
1 GB
Space
Space
20 GB SSD
Bandwidth
Bandwidth
30 Mbps
DDoS Protected SSD-KVM 1024 Linux

38 /mo

/mo

Billed annually

-10%

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

14.9 /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

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
400 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 16384 Linux

50 /mo

/mo

Billed annually

-16.2%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
50 GB SSD
Bandwidth
Bandwidth
60 Mbps
DDoS Protected SSD-KVM 4096 Linux

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