How To Find Laravel Version in Application?

Share this Article
Reading Time: 5 minutes
461 Views

There are several ways to find the laravel version which has been used for application development. We will see all possible ways to find laravel version of an application.

Inside this article we will see and discuss 4 ways to find laravel version of any laravel application. This article will clear you about How to find laravel version in application in a very easy and detailed way.

Why we need to know Laravel Version?

If any new developer is working on someone’s project which has been created in Laravel, first developer should know in which version it has been developed so that they will take care of next developments.

Learn More –

Let’s get started.


Installation of Laravel Application

Laravel Installation can be done in two ways.

  • Laravel Installer
  • By using composer

Laravel Installer

To install Laravel via Laravel installer, we need to install it’s installer first. We need to make use of composer for that.

$ composer global require laravel/installer

This command will install laravel installer at system. This installation is at global scope, so you type command from any directory at terminal. To verify type the given command –

$ laravel

This command will open a command palette of Laravel Installer.

To create ad install laravel project in system,

$ laravel new blog

With the name of blog a laravel project will be created at your specified path.

By using composer

Alternatively, we can also install Laravel by Composer command create-project. If your system doesn’t has Composer Installed, Learn Composer Installation Steps. Here is the complete command to create a laravel project-

$ composer create-project --prefer-dist laravel/laravel blog

After following these steps we can install a Laravel application into system.

To start the development server of Laravel –

$ php artisan serve

This command outputs –

Starting Laravel development server: http://127.0.0.1:8000

Assuming laravel already installed at system.


Methods To Find Laravel Version

Here, we will discuss about 4 ways to find laravel version in any laravel application.

  • By Artisan Command
  • Using Composer.json
  • By Using global helper function of Laravel
  • By Global Application Helper file

Let’s see all methods in action.

By Artisan Command

Open project in terminal and run this command into it.

$ php artisan -V

OR

$ php artisan --version

Using Composer.json

When you install laravel setup, you should see you have a file with name composer.json at application root.

Open file and search for “require”

You will see inside require object you have a property something like this –

"laravel/framework": "^8.40",

By Using global helper function of Laravel

In laravel, we have a global helper function provided for application as app()

By using this helper function we can call a version() method of it.

$version = app()->version();

Let’s create a small program which returns laravel version.

Open web.php file from /routes folder.

//...

Route::get("get-version", function(){

    $version = app()->version();

    dd($version);
});

//...

Start development server –

$ php artisan serve

URL – http://127.0.0.1:8000/get-version

By Global Application Helper file

This method is quite long to find laravel version. Because we need to find it into deeper file hierarchy.

We need to go inside Application.php which is a class file and also it’s a global application helper class.

File Path –

/vendor/laravel/framework/src/Illuminate/Foundation

We hope this article helped you to learn How To Find Laravel Version in Application in a very detailed way.

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.

Find More on Laravel 8 Articles here

Leave a Comment