In this tutorial, you will learn how to check the laravel version of your project. We often need to check the current version of the laravel to see the compatibility of the packages and for other various reasons.
We will be discussing 2 ways to check the laravel version of your project.
Just to let you know this tutorial is valid for mostly all versions of laravel including laravel 6, laravel 7, laravel 8 and laravel 9 as well.
So let’s get started.
Table of Contents
Method 1: Check Laravel Version Using Command line (Terminal)
In this method in order to check the laravel version, you just need to open the terminal and type the following command:
php artisan --version
That’s all you need to do and you will see that your Current Laravel Version will be displayed. For example:
Laravel Framework 9.6.0
Method 2: Check Laravel Version Using App Helper
Second method we have is using the app()
helper function. In app()
helper we have function call version()
that gives us the current version of project. It can be used in the controller or in the view blade file as well.
a) Check Laravel Version Using Controller
To check the laravel version using controller, type the the following code in the controller:
public function index(){
$app_version= app()->version();
return $app_version;
}
This will output you the current laravel version of the project
9.6.0
b) Check Laravel Version in Blade view file
Now to check laravel version In your blade view file, type the following code:
My Project Laravel version is {{ app()->version() }}
This will output gives you laravel version of your project
9.6.0
Conclusion
Hope you have learned today, two different ways of checking laravel version of your project. See you in the next one 🙂
Write a Reply or Comment