How to check laravel version using Terminal?

Laravel is one of the most popular PHP frameworks used for building web applications. It provides a wide range of features and functionalities that make it easy to create robust, scalable, and maintainable web applications. However, when it comes to maintaining and upgrading a Laravel application, knowing the current version is essential. In this article, we will explore different ways to check the Laravel version.

Using the Command Line Interface (CLI)

The simplest way to check the Laravel version is to use the Command Line Interface (CLI). Open your terminal or command prompt and navigate to the root directory of your Laravel project. Then type the following command:

php artisan --version

This command will display the Laravel version number installed in your project.

Checking the Composer File

Laravel is installed using the Composer package manager. The Laravel version number is specified in the composer.json file of your project. Open the file and look for the “require” section. You should see the Laravel version number in the “laravel/framework” package declaration.

"require": { "php": "^7.4|^8.0", "fideloper/proxy": "^4.4", "laravel/framework": "^8.0" },

Using the Artisan Command

Laravel provides an “artisan” command that can be used to perform various tasks. You can use the “tinker” command to check the Laravel version. Open your terminal or command prompt and navigate to the root directory of your Laravel project. Then type the following command:

php artisan tinker

This will launch the interactive shell. Type the following command to check the Laravel version:

app()->version();

This command will display the Laravel version number installed in your project.

Checking the Welcome Page

Laravel provides a default welcome page that is displayed when you access your application. The welcome page includes the Laravel version number in the footer section. Open your web browser and navigate to your Laravel application. Scroll down to the bottom of the page and look for the version number.

Checking the README File

When you create a new Laravel project, a README file is created in the root directory. The README file provides information about the project, including the Laravel version number. Open the README file and look for the “Laravel Version” section.

Using a Package

There are several Laravel packages available that can be used to check the Laravel version. One such package is “laravel-version”. Install the package using Composer and add the following code to your Laravel project:

use Nwidart\Version\Version; $laravelVersion = app(Version::class)->getVersion();

This code will retrieve the Laravel version number and store it in the $laravelVersion variable.

conclusion

there are several ways to check the Laravel version of your project. Whether you use the command line interface, the composer file, the artisan command, the welcome page, the README file, or a package, knowing the current version number is essential for maintaining and upgrading your Laravel application. Choose the method that works best for you and your project.

Comments