This is the fourth day of my participation in the August Text Challenge.More challenges in August

Before, I wrote an article about Laravel improving the efficiency of DB query. After forwarding it to the group, some people questioned me and said, “Laravel is the framework he used several years ago, I didn’t expect that there are still people using it now.”

Nani, what do you mean? Don’t forget PHP is the best language!

Personally, Laravel is a very elegant development framework: elegant design patterns, powerful feature implementations, easy extensions, constant release updates, and most importantly, the best technology development community to date, in my opinion.

I have to make a Call for Laravel.

Laravel released version 8.0 on September 8, 2020. Laravel is scheduled to release version 9.0 on January 25, 2022.

Here I would like to introduce the new features of the latest Laravel release (8.0) :

Laravel 8 with the introduction of Laravel Jetstream, model factory classes, Migration compression, queue batching, improved rate limiting, queue improvements, dynamic Blade components, Tailwind paging view, Time test Assistant, artisan Serve improvements, Improvements to the event listener, along with various other bug fixes and usability improvements, continue to improve Laravel 7.x.

The Laravel Jetstream and model Factory classes were introduced in the last article, and you can see that some people question whether I’m still developing with Laravel. Don’t forget PHP is the best language. (1)

Migrating compression, queue batching, improving rate limits, as I mentioned in this article, can you check it out and say I’m still developing with Laravel? Don’t forget PHP is the best language. (2)

Maintenance mode optimization

In previous versions of Laravel, the maintenance mode enabled by PHP Artisan Down can be bypassed by creating a whitelist of IP addresses that can access applications. This feature has been removed in favor of a simple “password” or token scheme.

In maintenance mode, you can use the Secret option to generate a token that bypassed maintenance mode:

php artisan down --secret="xxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"
Copy the code

After setting the app to maintenance mode, you can access the app’s URL with this token, and Laravel will write a cookie in the browser that bypasses maintenance mode:

https://example.com/xxxx-xxxx-xxxx-xxxx-xxxxxxxxxx
Copy the code

By hiding the route, you will be redirected to the application’s/route. Once the cookie is written to the browser, you can access the application as if it were not in maintenance mode.

Prerender maintenance mode view

If you are using PHP Artisan Down at deployment time and your users are accessing the application while updating composer dependencies or other underlying views, you may still occasionally get an error. This happens because Laravel must first enable some core functions to determine if your app is in maintenance mode and then render the maintenance mode view with the template engine.

For this reason, Laravel now allows you to pre-render a maintenance mode view at the very beginning of the request lifecycle. This view is rendered before any of the application’s dependencies are loaded. You can use the Render option of the Down command to select a pre-render template:

php artisan down --render="errors::503"
Copy the code

Closure distribution/chain catch

Using the new catch method, you can now specify a closure function to listen on a closure queue. When the closure queue has exhausted all the resets of the queue configuration and has not been completely successful, the closure function is executed:

use Throwable; dispatch(function () use ($podcast) { $podcast->publish(); })->catch(function (Throwable $e) {function (Throwable $e)});Copy the code

reading

Laravel code simplicity and performance optimization

Study group please click here, study together, common progress!!