Amidst the ever-growing demand for exceptional services and updates in the market, the core team at Laravel is determined to spare no effort in ensuring that it achieves the status of being the first choice for business owners. In line with this intent, they now present the latest investment in their franchise: Laravel 10. So, we’re here to inform you about What’s New in Laravel 10, showcasing the latest features and updates that will captivate developers and business owners, motivating them to upgrade their existing Laravel applications.

Laravel 10 Release Date

Laravel and its first-party packages adhere to the Semantic Versioning methodology, which involves releasing major updates to the framework once a year during the first quarter. Meanwhile, minor updates can be released as needed. Laravel 10, the most recent version of the framework, was officially launched on February 14, 2023. This update brings an array of exciting new features and improvements, showcasing the continuous evolution of the Laravel ecosystem. Previously, the core team released a new version of Laravel every six months. Following the launch of Laravel 9 in February 2022, the core team made a significant change in their approach, adopting an annual release schedule. The details of this schedule are as follows:

  • Laravel 9: February 8, 2022
  • Laravel 10: February 14, 2023
  • Laravel 11: February 6, 2024

According to the official Laravel News Page, scheduled bug fixes will be provided for Laravel 9 until August 8, 2023, and security fixes until February 6, 2024. The Laravel 10 development team plans to offer bug fixes for the framework until August 6, 2024, with security fixes being provided until February 4, 2025.

What’s New in Laravel 10: Explore the Latest Features and Updates

The core team behind the framework is always striving to provide the best experience for its users. Therefore, we recommend using version constraints like ‘^10.0’ when referring to the framework or its components in an application or package. This is because newer versions may introduce significant changes and updates. The current Laravel 10 also includes several substantial improvements that will benefit product owners. Let’s examine these changes more closely:

Dropped support for PHP 8.0

Laravel 10 no longer offers support for PHP 8.0, and you must upgrade to PHP 8.1 or 8.2. While it’s not necessary to update your Laravel applications immediately upon each new release, we still recommend thorough testing, especially for projects with paid clients or employees. Furthermore, upgrading to Predis v2 is required as support for Predis v1 has been discontinued along with PHP 8.0.

Laravel Pennant was introduced

The Laravel Pennant is an uncomplicated and efficient feature flag package designed to facilitate seamless implementation of new features in your application. It incorporates an A/B test interface design, supports trunk-based development strategies, and offers additional functionalities. The feature flags allow you to turn a feature on or off at runtime without modifying the code.

Simple Process Handling

Laravel simplifies and extends the API for the Symphony Process component, allowing you to effortlessly execute external processes within your Laravel application. This process functionality tackles common use cases and significantly enhances the development experience.

Invokable Validation Rules by Default

In Laravel 9, developers were required to add the “–invokable” flag after the artisan command when creating a new Invokable rule. However, Laravel 10 simplifies this process by allowing you to create a new Invokable rule with a straightforward command:

Additionally, developers can easily comprehend the straightforward boilerplate code, which reduces intimidation and enables them to create their own custom validation rules.

Application Skeleton Code with Type Declarations

Laravel has historically employed DocBlocks in its skeleton code to provide clear explanations of code functionality, along with the corresponding responses and parameters. However, the latest version of Laravel introduces Type Declarations, which entail the inclusion of type-hints and return types in all user code within the framework.

These improvements offer several advantages without compromising backward compatibility with the core framework. The enhancements involve Method Arguments, Return Types, reduction of redundant annotations whenever possible, exclusion of the Types property, and enabling users to access closure arguments.

Removed dispatchNow()

Laravel 10 has removed the ‘dispatchNow()’ method, which was deprecated in Laravel 9 in favor of ‘dispatchSync()’. It is crucial to replace this method in all your existing projects as it represents a breaking change. However, the solution is simple: remove the passive voice in this paragraph.

Deprecations from Laravel 9

The Laravel team is phasing out deprecated methods in the Laravel 10 branch that were present in Laravel 9 with the recent update. The Laravel documentation includes an updated upgrade process, which contains a list of all deprecated methods and packages.

Planning to upgrade projects to Laravel v10 will require developers to rewrite their code using a new approach to achieve the desired outcome. Laravel v10 introduces several deprecations and deletions compared to version 9 and the master branch. These changes necessitate a proactive approach in code modification.

  • The Route::home method, which was removed in Laravel 9
  • The getBaseQuery method, which has an equivalent toBase method
  • The MaintenanceModeException class is now obsolete and no longer in use
  • The MocksApplicationServices trait
  • The Mail::failures method in the mail fake
  • I recommend using $casts instead of the deprecated $dates property
  • The method assertTimesSent()
  • Predis 1 and doctrine/dbal 2 no longer have available support
  • All related deprecations in doctrine/dbal since Laravel has dropped support for version 2.

Should You Upgrade to Laravel 10?

It is essential to understand that Laravel is an open-source framework. When you install a new instance on your device, you gain ownership of the codebase. This means that even if the version you have is no longer supported, your application will continue to operate. However, it is important to note that you will be solely responsible for maintaining that particular version. It is recommended to prioritize stability over upgrading the framework. You should consider upgrading to Laravel 10 only under specific circumstances:

  • Your existing Laravel application is robust and operating flawlessly
  • The upgrade will introduce a vital functionality or address a crucial issue that will significantly improve the performance of your app.
  • You have extensively tested your application prior to implementing the upgrade in the production environment.

How to Upgrade from Laravel 9 to Laravel 10

Upgrading your current Laravel application to the new version, Laravel v10, will be effortless with Laravel 10.x Shift’s official release. This tool streamlines the process of upgrading from Laravel 9 to Laravel 10, effectively saving users up to 2 hours of precious time. It is important to acknowledge that both Laravel and Laravel 10.x Shift will continuously receive updates, and users of Shift can request a rerun of the tool if needed.

Requirements

To upgrade your existing Laravel application to Laravel 10, certain important prerequisites need to be fulfilled.

  • Your Laravel application should be running on Laravel version 9 or a higher version
  • Please ensure that your server has PHP 8.1 or a more recent version installed.

Core Upgrades

The Shift automates many of the upgrades outlined in the Laravel Upgrade Guide, including various enhancements and improvements.

  • Upgrades to the core project files of Laravel
  • Innovative approaches for modifications implemented in interfaces
  • Add PHP-type hints to the Laravel app
  • To convert the deprecated $dates property to $casts
  • To update the core dependencies for Laravel 10 and PHP 8.1
  • Remove redundant typing within PHP DocBlocks
  • Detection of deprecated code within the app code.

Additional Upgrades

Along with the core upgrades, the Shift also includes additional upgrades mentioned in the Laravel Upgrade Guide, such as:

  • The PHP syntax modernized by incorporating the null safe operator and short arrays
  • Ability to apply your preferred code style
  • Adoption of tuple syntax and implementation of class-based routes
  • Conversion to anonymous migrations
  • Automated changes required for PHPUnit 9
  • Transformation of Faker property access to method calls
  • Update the config files to reflect the Laravel 10 versions
  • Increased dependency constraints for popular packages.

Manual Upgrades

The Laravel 10.x Shift endeavors to automate the majority of upgrades, streamlining the process. However, certain updates may require manual intervention, which the shift identifies and communicates through comprehensive instructions in the pull request. These instructions outline the precise steps needed for manual implementation, ensuring a complete and accurate upgrade.

While the Shift aims to identify and automate the identification of updates for commonly used dependencies, there might still be instances where manual intervention is necessary. To ensure a smooth upgrade process, it is advisable to carefully review the changelog for dependencies and any other associated modifications. This will help guarantee a successful upgrade without any issues.

Conclusion

We have concluded our overview of What’s New in Laravel 10, which includes its features, updates, and requirements. We hope this blog post has provided you with significant insight into the latest version of the framework. If you’re a business owner unsure about whether to upgrade your existing Laravel application to Laravel 10 or if you’re considering a new project and wondering if Laravel is the right solution for your needs, you can hire a Laravel Development Company like iCreatewebtech. Our team of experts will guide you through every step of your web application development journey, alleviating any stress or concerns you may have.