Tuesday, April 16, 2024
HomePHPLaravel 9.28 Launched | Laravel Information

Laravel 9.28 Launched | Laravel Information


The Laravel crew launched 9.28 with console sign traps, check view knowledge assertions, forestall silently discarding fillable values, and extra:

Add view knowledge assertions to TestView

Andrew Brown contributed three TestView assertion strategies to claim view knowledge:

1$view = $this->view('welcome', [

2 'name' => 'Taylor',

3 'email' => 'user@example.com'

4]);

5 

6$view->assertViewHas('identify'); // true

7$view->assertViewHas('identify', 'Tyler'); // false

8 

9$view->assertViewHasAll(['name', 'email']); // true

10$view->assertViewHasAll([

11 'name' => 'Taylor',

12 'email' => 'user@example.com',

13]); // true

14 

15$view->assertViewMissing('nonda'); // true

16$view->assertViewMissing('identify'); // false

Get the meant session URL from the redirector

D. Nagy Gergő contributed a getIntendedUrl() technique on the Redirector class to each get and set the meant redirect URL:

1$redirect->setIntendedUrl('http://foo.com/bar');

2$redirect->getIntendedUrl(); // http://foo.com/bar

Eloquent mode to stop silently discarding fills for attributes

Ralph J. Smit contributed a mannequin technique to stop discarding fills even when a mannequin will not be completely guarded. That is helpful should you work on a Laravel codebase that makes use of fillable fields, however you additionally do not wish to silently discard knowledge handed.

This mannequin is toggleable in a number of methods; for instance, you would use the setting to solely set off an exception in non-production environments:

1Mannequin::preventSilentlyDiscardingAttributes();

2 

3// Solely forestall in non-production environments

4Mannequin::preventSilentlyDiscardingAttributes(

5 ! app()->isProduction()

6);

Sign traps

Nuno Maduro contributed the introduction of sign traps that means that you can catch course of indicators and execute code once they happen:

1$this->entice(SIGINT, operate () {

2 // Finish the command's job gracefully ...

3 // E.g: clear created recordsdata, and many others ...

4 

5 $this->proceed = false;

6});

7 

8// entice a number of indicators

9$this->entice([SIGTERM, SIGQUIT], operate ($sign) {

10 

11 $this->operating = false;

12 

13 dump($sign); // SIGTERM or SIGQUIT

14});

Help passing Enumerable objects to Stringable strategies

Erik Gaal contributed the power to move enumerable objects to Stringable helper capabilities:

1// Earlier than

2Str::take away($months->toArray(), $someString);

3 

4// After with an Enumerable object

5Str::take away($months, $someString);

Launch Notes

You may see the whole listing of recent options and updates beneath and the diff between 9.27.0 and 9.28.0 on GitHub. The next launch notes are instantly from the changelog:

v9.28.0

Added

  • Added view knowledge assertions to TestView (#43923)
  • Added Illuminate/Routing/Redirector::getIntendedUrl() (#43938)
  • Added Eloquent mode to stop prevently silently discarding fills for attributes not in $fillable (#43893)
  • Added Illuminate/Testing/PendingCommand::assertOk() (#43968)
  • Make Utility macroable (#43966)
  • Introducing Sign Traps (#43933)
  • Permit registering situations of instructions (#43986)
  • Help Enumerable in Stringable (#44012)

Fastened

  • Fastened RoueGroup::merge to format merged prefixes accurately. (#44011)
  • Fixes providesTemporaryUrls on AwsS3V3Adapter (#44009)
  • Repair ordering of stylesheets when utilizing @vite (#43962)

Modified

  • Permit invokable guidelines to specify customized messsages (#43925)
  • Help objects like GMP for customized Mannequin casts (#43959)
  • Default 404 message on denyAsNotFound (#43901)
  • Modified Illuminate/Container/Container::resolvePrimitive() for isVariadic() (#43985)
  • Permit validator messages to make use of nested arrays (#43981)
  • Guarantee freezeUuids at all times resets UUID creation after exception in callback (#44018)
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments