Laravel developers are constantly adding new features to new versions of the framework. If you want to know whether your installation supports a specific feature, you should know your version of Laravel.
This article will show several ways to check the Laravel version in the command line or your code. You can use the artisan command, the app() helper, or just get the version from Composer.
How to Find Laravel Version
The simplest way to check the version of Laravel in the command line is to run this artisan command:
php artisan --version

It will print a string that will contain the framework name and version. Also, you can use the composer show command that will display information about any package:
composer show laravel/framework

If you want to get Laravel version in code, there are multiple ways to achieve it. The version is defined as the VERSION class constant in Illuminate\Foundation\Application class.

The app() helper returns the object of an Illuminate\Foundation\Application class. So you can call the version() method from the app() helper. It will return a string with the current version and will work everywhere:
$version = app()->version();

If you don’t like using global helpers, you can resolve the Application class using the dependency injection mechanism. For example, in the controller:
use Illuminate\Foundation\Application;
//...
public function __invoke(Application $app)
{
$version = $app->version();
}
If you want to get the version in any Command class, you don’t have to use the app() helper. The Laravel Application class can be accessed by $laravel property. For example:
$version = $this->laravel->version();
Besides, you can get the version by calling the getVersion() method in Symfony\Component\Console\Application. For example:
$version = $this->getApplication()->getVersion();
Also, you can check the version of any installed package using Composer\InstalledVersions class. It has a static getVersion() method that expects a package name as the first argument. For example:
use Composer\InstalledVersions;
//...
$version = InstalledVersions::getVersion("laravel/framework");

Wrapping Up
As you can see, there are no issues with getting a version of the Laravel framework. You can use the command line, Illuminate\Foundation\Application class, or Composer package manager.