DEV Community

Cover image for Define a Route Group Controller in Laravel 8.80
Suresh Ramani
Suresh Ramani

Posted on • Originally published at techvblogs.com

5

Define a Route Group Controller in Laravel 8.80

The Laravel crew launched 8.80 with the power to outline a route group controller, render a string with the Blade compiler, PHPRedis serialization and compression config assist, and the most recent modifications within the v8.x department.

Specify a Route Group Controller

Luke Downing contributed the ability to define a controller for a route group, meaning you don't have to repeat which controller a route uses if the group uses the same controller:

use App\Http\Controllers\OrderController;

Route::controller(OrderController::class)->group(function () {
    Route::get('/orders/{id}', 'show');
    Route::post('/orders', 'store');
});
Enter fullscreen mode Exit fullscreen mode

A great thing has been added in Laravel 8.80, https://github.com/laravel/framework/pull/40276 which is the use of Route::controller() with Groups to shorten Route, so I want to share it with you so that you may use it in your next projects.

Render a String With Blade

Jason Beggs contributed a Blade::render() a technique that makes use of the Blade compiler to transform a string of Blade templating right into a rendered string:

// Returns 'Hello, TechvBlogs'
Blade::render('Hello, {{ $name }}', ['name' => 'TechvBlogs']);

// Returns 'Foo '
Blade::render('@if($foo) Foo @else Bar @endif', ['foo' => true]);

// It even supports components :)
// Returns 'Hello, TechvBlogs'
Blade::render('<x-test name="TechvBlogs" />');
Enter fullscreen mode Exit fullscreen mode

PHPRedis Serialization and Compression Config Help

Petr Levtonov contributed the power to configure PHPRedis serialization and compression choices as a substitute for needing to overwrite the service supplier or outline a customized driver.
The PR launched the next serialization choices:

  • NONE
  • PHP
  • JSON
  • IGBINARY
  • MSGPACK

These options are now documented in the Redis - Laravel documentation.

Thank you for reading this blog.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Cloudinary image

Zoom pan, gen fill, restore, overlay, upscale, crop, resize...

Chain advanced transformations through a set of image and video APIs while optimizing assets by 90%.

Explore

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay