DEV Community

Morcos Gad
Morcos Gad

Posted on • Edited on

Laravel 9.32 Release ( Adds source file to dd function output and more ...... )

In the new version 9.32 we have Some of the new features.

<!-- current syntax --> <x-profile :user-id="$userId"></x-profile> <!-- short syntax --> <x-profile :$userId></x-profile> 
Enter fullscreen mode Exit fullscreen mode

dd() and dump() output, adding the source file and line

This adds methods to conveniently retrieve and cast request data as an int and float. A bool cast already existed. So why not have other common scalar types.

intval($request->input('some_int_value')); floatval($request->input('some_float_value')); // Now $request->integer('some_int_value'); $request->float('some_float_value'); 
Enter fullscreen mode Exit fullscreen mode
intval(str('shift-worker-01')->afterLast('-')->toString()); floatval(str('Result: 1.23')->after(':')->trim()->toString()); str('YeS')->lower()->toString() === 'yes'; Carbon::parse(str('DOB: 12-31-2001')->after(':')->trim()->toString()); // Now str('shift-worker-01')->afterLast('-')->toInteger(); str('Result: 1.23')->after(':')->trim()->toFloat(); str('YeS')->lower()->toBoolean(); str('DOB: 12-31-2001')->after(':')->trim()->toDate(); 
Enter fullscreen mode Exit fullscreen mode
enum Status: string { case Published = 'published'; case Draft = 'draft'; } Route::get('/posts/{status}', function(Status $status) {}); Route::get('/posts/{status?}', function(Status $status = Status::Published) {}); 
Enter fullscreen mode Exit fullscreen mode

One benefit is that you can commit encrypted files to version control, thus versioning your development setup, staging, etc.

# Looks for .env and creates .env.encrypted php artisan env:encrypt # Use a supported cipher php artisan env:encrypt --cipher=aes-256-cbc # Looks for .env.production and creates .env.production.encrypted php artisan env:encrypt --env=production 
Enter fullscreen mode Exit fullscreen mode

To decrypt an encrypted file, you can use the following artisan command

# Decrypts .env.encrypted to create a .env file php artisan env:decrypt --key=h9kAPUmxdZ8ZbwT3 # Specify options php artisan env:decrypt \ --key=h9kAPUmxdZ8ZbwT3 \ --env=production \ --filename=.env" 
Enter fullscreen mode Exit fullscreen mode
  • test the performance with the Benchmarking helper

https://laravel-news.com/laravel-benchmark
https://github.com/laravel/framework/pull/44297
https://www.youtube.com/watch?v=a4cLlxQjMTk
https://www.youtube.com/watch?v=ubYl20CG_MM
https://laravel.com/docs/9.x/helpers#benchmarking

// Before... Benchmark::dd(fn () => sleep(1)); // 1002.61591713213123 // After... Benchmark::dd(fn () => sleep(1)); // "1,002.615ms" 
Enter fullscreen mode Exit fullscreen mode

More about Benchmark :-
https://www.youtube.com/watch?v=I0ZngrKbemI
https://github.com/laravel/framework/commit/b4293d7c18b08b363ac0af64ec04fb1d559b4698

case-insensitive support to Stringable contains() and containsAll() methods

// returns true $this->stringable('taylor') ->contains(['LOR'], true); // returns true $this->stringable('taylor otwell') ->containsAll(['TAYLOR', 'OTWELL'], true); 
Enter fullscreen mode Exit fullscreen mode
enum UserRoles: string { case ADMIN = 'Admin'; } // routes/web.php Route::get('/', function () { return view('dashboard', ['role' => UserRoles:: ADMIN]); }); // dashboard.blade.php Hello, {{ $role }}. // ❌ Before: TypeError: htmlspecialchars(): Argument #1 ($string) must be of type string // ✅ After: Hello, Admin. 
Enter fullscreen mode Exit fullscreen mode
<!-- current short syntax --> <x-profile :$userId></x-profile> <!-- short syntax for self-closing component --> <x-profile :$userId/> 
Enter fullscreen mode Exit fullscreen mode

I hope you enjoyed with me and to learn more about this release visit the sources and search more. I adore you who search for everything new.

Source :- https://www.youtube.com/watch?v=0yc9mY_MPxI
Source :- https://laravel-news.com/laravel-9-32-0
Source :- https://laravel-news.com/laravel-9-34-0
Source :- https://www.youtube.com/watch?v=AjOnRIj3-UQ

Top comments (0)