Some Cool features of Laravel 8
Laravel is a most popular framework of PHP and it has a great Community support. We can easily find forums as well as Laravel communities if we need some answers with Something. Laravel 8 comes with exciting new features. This post contains a summary of some of the new capabilities announced. Let’s take a look at some of those great new features!
# Maintenance Mode
some new attributes has been added to maintenance mode like if I want to instruct the browser to refresh the page in specified seconds.
php artisan down — refresh=15
If I want to access the web using www.example.com/1630542a-246b-4b66-afa1-dd72a4c43515 while the website still down.
php artisan down — secret="1630642a-246b-4b66-afa1-dd72a4c43516"
Now I can tell Laravel to redirect all requests to the specified routes when maintenance.
php artisan down — redirect=/
# Rate Limiter
In Laravel 8, we limit the HTTP request in the RouteServiceProvider where it’s very flexible to use.
RateLimiter::for('uploads', function (Request $request) { return Limit::perMinute(1000);
});
# Laravel Octane
Octane is the latest Official Laravel package where it makes your application run on top of the Swoole server. Running the Laravel using Octane will make the app performance up to 10x faster than traditional artisan serve. Also, in Octane, we can run the PHP codes asynchronously/concurrently so it can handle a lot of heavy tasks in no time.
[$users, $servers] = Octane::concurrently([ fn () => User::all(), fn () => Server::all(),
]);
Octane also has a feature to use the Swoole Table, where it can perform extreme read/write for your app. Also, we can use cache using Swoole as the driver.
# Job Batching
Job Batching features are useful when we want to execute some jobs at the same time (but not concurrently) and we can catch the callback whether the job is successfully executed or not.
# Laravel Jetstream
Jetstream is a package where it provides us the scaffolding/boilerplate for our starting point in the project. It has abundant features such as user profile management, authentication, email verification, 2FA, team management features, etc.
# Squashing Migration
When the project gets bigger and bigger, we may notice that we have a lot of migration files. In Laravel 8, we can squash all of the migration files into one single SQL schema.
php artisan schema:dump --prune
With that command, we’ll have a schema file and whenever we run the artisan migrate, Laravel will execute the schema file first then check the remaining migration files.
# Route Caching
Laravel uses route caching to compile your routes in a PHP array that is more efficient to deal with. In Laravel 8, it’s possible to use this feature even if you have closures as actions to your routes. This should extend the usage of route caching for improved performance.