How to Check Laravel Version?

Laravel is one of the most popular PHP frameworks for building robust web applications.

The Laravel version is important when we are working with packages, updates, or documentation specific to a version. Because its newer versions are released with significant improvements, new features or security updates.

This article provides three methods to check the accurate Laravel versions.

Methods to Check Laravel Version

  • Using the Command Line Interface (CLI)
  • Checking the composer.json File
  • Viewing the VERSION File (For Older Versions)

a) Using the Command Line Interface (CLI)

The easiest way to find out your Laravel version is through the command line. Below we describe that:

1. Navigate to Your Laravel Project: Open your terminal or command prompt and navigate to the root directory of your Laravel project. like this:

cd /path/to/your/laravel/project

2. Run the Artisan Command: Laravel comes with an Artisan built-in command-line tool. Run the following command to display your Laravel version:

php artisan --version

Output:

Laravel Framework 10.x.x

This will print the version of your current Laravel framework, such as Laravel Framework 10.12.0.

b) Checking the composer.json File

Your composer.json file contains all the dependencies and versions for your Laravel project.

1. Open the composer.json File: Use any text editor or IDE to open the composer.json file in your project root directory.

2. Locate the Laravel Framework Entry: Look for the line under the require section:

"require": {
"laravel/framework": "^10.0"
}

Here, this shows your version, such as ^10.0.

c) Viewing the VERSION File (For Older Versions)

In older Laravel versions, it contains a VERSION file in the root directory of your project. And that file stores a Laravel version. This method is less common for newer versions, but can be used as a fallback.

1. Navigate to the Root Directory: Use the command line to move to your Laravel project’s root path:

cd /path/to/your/laravel/project

2. Display the VERSION File Content: Use the following command:

cat VERSION

This will display the version number if the file exists.

How To Update Laravel Version?

Laravel updates are useful for the latest features and maintain compatibility with current PHP versions and packages.

What is composer update?

composer update is a command that updates the PHP packages listed in your project’s composer.json file.

But it doesn’t always update Laravel to the latest version.

If your composer.json file already allows the latest version of Laravel, like this:

"laravel/framework": "^10.0"

Then running this command:

composer update

It will upgrade Laravel to the latest 10.x version (like 10.40, 10.41, etc).

But it won’t work if your Laravel version is locked

For example, if your composer.json contain this line:

"laravel/framework": "^9.0"

Then composer update will only install the latest version of Laravel 9, not Laravel 10 or 11.

So, how do you upgrade to Laravel 10 or higher?

Do the following steps:

  1. Open your composer.json file
  2. Change this line manually: “laravel/framework”: “^10.0”
  3. Then run this command: composer update

Laravel will now be updated to version 10.x.

Conclusion

Knowing your Laravel version is essential for maintaining a smooth development workflow and troubleshooting. Use the above methods to quickly find out your Laravel version, and stay informed with up-to-date information.

Also Learn : Top 50 Laravel Interview Questions

How to Check Laravel Version

You can use the Command Line Interface (CLI) to check the Laravel version. First, open a terminal and navigate to your project root, then run this command: php artisan –version.

How To Update Laravel Version?

Open your terminal and run this command: composer update

Leave a Comment