198

How to know Laravel version and where is it defined?

Is Laravel version is defined inside my application directory or somewhere in global server side directory?

UPDATE

Sorry, the main question is where the version is defined? Where does

php artisan --version

takes it's answer?

UPDATE 2

The goal is to investigate, who (of us) has changed Laravel version on our site. Could it be changed by github repository edition only? Or server write access was also required?

1
  • Do you want to use version in your code ?
    – Vikash
    Jun 19, 2017 at 19:14

15 Answers 15

202

run php artisan --version from your console.

The version string is defined here:

https://github.com/laravel/framework/blob/master/src/Illuminate/Foundation/Application.php

/**
 * The Laravel framework version.
 *
 * @var string
 */
 const VERSION = '5.5-dev';
4
  • 18
    composer.json also look :) Jun 19, 2017 at 18:49
  • @NikolaSpalevic That was my first thought, but with semantic version numbers you won't see the patch number. If you run the artisan command you will.
    – Ryan Kozak
    Jun 19, 2017 at 18:51
  • @btl please, also answer the second part, where is it defined?
    – Dims
    Jun 19, 2017 at 18:54
  • Good point mentioning Application.php as Laravel doesn't seem to know its version sometimes. My composer.json says "5.6.*", the constant knows it's "5.6.18", but using "artisan --version" gives me: "Laravel Framework 7.8.1" - which doesn't even exist.
    – Select0r
    Feb 26, 2019 at 9:07
50
  1)  php artisan -V

  2)  php artisan --version

AND its define at the composer.json file

"require": {
        ...........
        "laravel/framework": "^6.2",
        ...........
    },
1
  • The composer.json should be the real answer, you can tell which version it is without even having to have PHP installed in your system. Feb 2, 2022 at 13:32
36

If you want to know the specific version then you need to check composer.lock file and search For

"name": "laravel/framework",

you will find your version in next line

"version": "v5.7.9",

1
  • 1
    Except you'd want 5.4.* so you can install security patches. Which still won't tell you the version number then :)
    – Jebble
    Aug 31, 2018 at 12:40
31

If you want to know the user version in your code, then you can use using app() helper function

app()->version();

It is defined in this file ../src/Illuminate/Foundation/Application.php

Hope it will help :)

17

CASE - 1

Run this command in your project..

php artisan --version  

You will get version of laravel installed in your system like this..

enter image description here

CASE - 2

Also you can check laravel version in the composer.json file in root directory.

enter image description here

10

Step 1:

go to: /vendor/laravel/framework/src.Illuminate/Foundation:

go to: <code>/vendor/laravel/framework/src.Illuminate/Foundation</code>

Step 2:

Open application.php file

Open application.php file

Step 3:

Search for "version". The below indicates the version.

Open application.php file

2
  • 1
    A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.
    – Zoe
    Aug 24, 2019 at 9:49
  • 1
    This answer should be reformatted to have the links render as images. You will be less likely to be flagged for low quality if you do.
    – theMayer
    Aug 24, 2019 at 13:03
7

Run this command in your project folder location in cmd

php artisan --version
0
5

Yet another way is to read the composer.json file, but it can end with wildcard character *

1
  • Incorrect. The composer.json doesn't show the installed version. It show the minimum version required and upgrade policy. If you upgraded your app, chances are it won't match your composer.json. Instead you should look at the composer.lock, this file shows the currently installed version of all dependencies.
    – LobsterBaz
    Apr 29, 2021 at 22:22
4

Multiple way we can find out laravel version such as,

Using Command

php artisan --version
  or
php artisan -v

From Composer.json

From Vendor Directory

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

In your Laravel deployment it would be

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

to see who changed your Laravel version look at what's defined in composer.json. If you have "laravel/framework": "5.4.*", then it will update to the latest after composer update is run. Composer.lock is the file that results from running a composer update, so really see who last one to modify the composer.json file was (hopefully you have that in version control). You can read more about it here https://getcomposer.org/doc/01-basic-usage.md

2

You can also check with composer:

composer show laravel/framework
2

If you're like me and want to show the Laravel version and app version on the footer you can create a Blade directive in AppServiceProvider. Blade directives are placed in the boot method of the AppServiceProvider and example code may like something like


Blade::directive('laravelVersion', function () {
    return "<?php echo app()->version(); ?>";
});

then in the blade template, you call it like @laravelVersion and it will show the current laravel version.

If you want, you can read more about blade directive here

2

You can find this on Composer.json file -> root directory

1

You can view the result of dd(\Illuminate\Foundation\Application::VERSION)

1

If you are using Laravel 9 or higher. You can get a quick overview of your application's configuration, drivers, and environment via the about Artisan command:

php artisan about

Official doc Application Overview

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.