How to check laravel application version using CLI or file

Laravel is a popular framework built with PHP. While working on an existing project or implementing new packages we need to check particular package is compatible with the Laravel framework’s version or not. We have to decide based on the Laravel version.

In this tutorial, we will teach you how to check the Laravel framework’s version using the below methods:

  • Check Laravel Version Using CLI
  • Check Laravel Version In File

Both methods return the same output on any operating system. You can use a command prompt or terminal to check the Laravel version using CLI or you can navigate to the particular file using file manager and check it.

Check Laravel Version Using CLI

Artisan is a useful and very powerful command line tool pre-loaded with the Laravel framework. As you know artisan is used for many tasks like creating models, migration, controller or clearing cache, and many more.

To check the Laravel version using Artisan, first of all, open a terminal or command prompt based on your OS. Now navigate to the root directory or your application and execute the below command:

php artisan --version

It will show the Laravel framework version in the console like the below output :

Laravel Framework 8.83.6

Check Laravel Version In File

Sometimes working on a server or by signing in non-root users you don’t have terminal access to the application directory. In such cases, you can use this method. Here, we will check the version using framework files downloaded while creating a new application.

Open the file manager and navigate to the root directory of the application. Find and open the below file :

./vendor/laravel/framework/src/Illuminate/Foundation/Application.php

Open this file in any text editor and search for VERSION. Here, you will find a constant variable by VERSION name and its value contains the Laravel application’s version like the below example :

/**
 * The Laravel framework version.
 *
 * @var string
 */
const VERSION = '8.83.6';

Mostly, it is the first variable defined in the application class. It will show the same version as a command line.

Conclusion

In this article, you have learned to check the Laravel framework version using a terminal or command line as well as manually check by files. It will be helpful to know the version of Laravel while working on any application.