Overview Laravel v8.55.0 introduces a series of powerful quality-of-life enhancements designed to streamline common developer workflows. From modernizing security protocols with **GCM encryption** to providing more granular control over **Soft Deleted** models in routing and validation, this release focuses on making the framework more expressive. These updates reduce boilerplate and improve the developer experience by introducing intuitive methods for rate limiting and data extraction. Prerequisites To follow this guide, you should have a solid grasp of the PHP programming language and the Laravel framework. Familiarity with **Eloquent ORM**, **Route-Model Binding**, and the **Validation** component is essential for implementing these new features effectively. Key Libraries & Tools - **Laravel Framework**: The core PHP framework providing the updated features. - **OpenSSL**: Underlying library used for the new **AES-GCM** encryption ciphers. - **Eloquent ORM**: Used for handling **Soft Deletes** and database interactions. Code Walkthrough 1. Modernizing Encryption with GCM Laravel now supports **AES-128-GCM** and **AES-256-GCM**. These ciphers offer better performance and security compared to the older CBC mode. You can update your cipher in `config/app.php`: ```php 'cipher' => 'AES-256-GCM', ``` 2. Streamlined Rate Limiting The new `attempt()` method on the `RateLimiter` facade replaces manual counter checks with a single callback-based execution. ```php RateLimiter::attempt( 'send-message:'.$user->id, $maxAttempts = 5, function() { // Logic to execute if limit not reached }, $decaySeconds = 60 ); ``` 3. Route-Model Binding with Soft Deletes You can now easily retrieve models that have been soft-deleted by chaining `withTrashed()` directly onto your route definition. ```php Route::get('/profile/{user}', function (User $user) { return $user; })->withTrashed(); ``` 4. Advanced Validation Features The `Rule::when()` method allows for cleaner conditional logic within your validation arrays, while the `safe()` method provides a fluent interface for interacting with validated data. ```php $validator = Validator::make($data, [ 'seats' => [ 'integer', Rule::when($isBasePlan, ['max:100']), ], ]); $validated = $validator->safe()->only(['seats']); ``` Syntax Notes Notice the shift toward **fluent interfaces**. Methods like `withTrashed()` and `withoutTrashed()` allow developers to describe database constraints in plain English. The `Rule::when()` method accepts a boolean or a closure, providing flexibility for dynamic validation scenarios without messy `if` statements. Practical Examples - **API Throttling**: Use the `attempt()` method to wrap sensitive API endpoints, ensuring users don't exceed rate limits while keeping the controller code clean. - **Administrative Dashboards**: Use `withTrashed()` in routes to allow administrators to view or restore deleted records via the same URL structure used for active records. Tips & Gotchas When switching to **GCM encryption**, you must decrypt your existing data with the old cipher before re-encrypting it with the new one. Failure to do so will result in `DecryptException` errors across your application. Always verify your encryption key is set correctly before performing a mass migration of encrypted data.
Laracon Online
Events
Aug 2021 • 1 videos
High activity month for Laracon Online. Laravel among the most active voices, with 1 videos across 1 sources.
Aug 2021
- Aug 19, 2021