We are 50+ professional Software Developers with more than 5+ years of experience in delivering solutions.

Contacts

B-1001, PNTC, Prahalad Nagar, Ahmedabad

+91 63548-55130 | +1 707-901-7072

Laravel
Whats-New-in-Laravel-10-Top-7-Features-to-Watch-Out-For

What’s New in Laravel 10: Top 7 Features to Watch Out For

Laravel is a popular PHP framework that provides developers with powerful tools for building web applications. Laravel releases new versions regularly, and Laravel 10 is the latest major release as of 14th February 2023. The release notes for Laravel 10 can be found on the Laravel documentation site.

The release notes provide detailed information about the new features, enhancements, and bug fixes included in Laravel 10. Some of the notable changes in Laravel 10 include the introduction of argument and return types to all application skeleton methods and stub files, improvements to the routing system, and enhancements to the testing tools.

Essential Server requirement for Laravel 10:

  • PHP version 8.1 or higher
  • Ctype PHP Extension
  • cURL PHP Extension
  • DOM PHP Extension
  • Fileinfo PHP Extension
  • Filter PHP Extension
  • Hash PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension

Type Hints

<?php
 
namespace App\Http\Controllers;
 
use App\Models\Flight;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
 
class FlightController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index(): Response
    {
        //
    }
 
    /**
     * Display the specified resource.
     */
    public function show(Flight $flight): Response
    {
        //
    }
 
    // ...
 
}


Type hints are a powerful feature that allows developers to specify the data type that a function or method expects to receive as input. In Laravel 10, type hints are being introduced for more functions and methods, which will make it easier to write code that is more reliable and easier to maintain.

Laravel Pennant

use Laravel\Pennant\Feature;
use Illuminate\Support\Lottery;
 
Feature::define('new-onboarding-flow', function () {
    return Lottery::odds(1, 10);
});

Once a feature has been defined, you may easily determine if the current user has access to the given feature:

if (Feature::active('new-onboarding-flow')) {
    // ...
}

Of course, for convenience, Blade directives are also available:

@feature('new-onboarding-flow')
    <div>
        <!-- ... -->
    </div>
@endfeature


Laravel Pennant is a new feature that is being introduced in Laravel 10, which allows you to easily create custom banners for your application. With Laravel Pennant, you can create banners that promote new features, notify users of maintenance or downtime, or display any other message that you need to communicate to your users.

Process Interaction

use Illuminate\Support\Facades\Process;
 
$result = Process::run('ls -la');
 
return $result->output();

Processes may even be started in pools, allowing for the convenient execution and management of concurrent processes:

use Illuminate\Process\Pool;
use Illuminate\Support\Facades\Pool;
 
[$first, $second, $third] = Process::concurrently(function (Pool $pool) {
    $pool->command('cat first.txt');
    $pool->command('cat second.txt');
    $pool->command('cat third.txt');
});
 
return $first->output();

In addition, processes may be faked for convenient testing:

Process::fake();
 
// ...
 
Process::assertRan('ls -la');


Process Interaction is another new feature that is being introduced in Laravel 10, which makes it easier to interact with other processes running on your system. With Process Interaction, you can send signals to other processes, retrieve information about running processes, and more.

Test Profiling

use Illuminate\Support\Facades\DB;

DB::enableQueryLog();

// Run some queries...

$queries = DB::getQueryLog();
$total_time = 0;

foreach ($queries as $query) {
    $total_time += $query['time'];
}

$avg_time = $total_time / count($queries);


Test Profiling is a new feature that allows you to measure the performance of your tests, so you can identify which tests are taking the most time to run. This can be especially helpful if you have a large test suite that takes a long time to run, as it can help you identify which tests you need to focus on optimizing.

Pest Scaffolding

php artisan pest:scaffold --unit


Pest Scaffolding is a new feature that is being introduced in Laravel 10, which makes it easier to get started with testing using the Pest testing framework. With Pest Scaffolding, you can generate boilerplate test code for your application, which can help you get started with testing more quickly and easily.

Generator CLI Prompts

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class MakeTaskCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'make:task {name : The name of the task}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create a new task';

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function handle()
    {
        $name = $this->argument('name');

        if ($this->confirm('Do you want to create a migration for this task?', true)) {
            $this->call('make:migration', [
                'name' => 'create_'.$name.'_table',
                '--create' => $name
            ]);
        }

        $this->info('Task created successfully.');
    }
}


Generator CLI Prompts is a new feature that makes it easier to generate code using the Laravel command-line interface. With Generator CLI Prompts, you can answer a series of questions about the code you want to generate, and Laravel will generate the code for you automatically.

Horizon / Telescope Facelift

php artisan horizon:install

php artisan horizon:assets

php artisan telescope:install

php artisan telescope:assets


Horizon and Telescope are two popular Laravel packages that provide powerful tools for monitoring and debugging your application. In Laravel 10, both Horizon and Telescope are getting a facelift, with improved user interfaces and new features that make it easier to monitor and debug your application.

Overall, Laravel 10 is shaping up to be an exciting release that will introduce a range of new features and improvements to the popular PHP framework. Developers can look forward to improved performance, easier testing, and new tools for monitoring and debugging their applications.

If you like this post then you may also like to share the same with your colleagues. Let us know your thoughts on our blogs and on social media posts on InstagramFacebookLinkedIn, and Twitter.

Get updates to our latest 10 blogs:

  1. 10 Reasons to Invest in Custom Software Development
  2. The Benefits of a Strong Web Development Team for Your Business
  3. The Future of Mobile App Development: Trends to Watch
  4. Unlock the Power of Progressive Web Apps: Discover the Benefits and Learn How
  5. The Ultimate Guide to Improving Website Speed and Performance: Essential SEO Tips and Techniques

Leave a comment

Your email address will not be published. Required fields are marked *