How to determine the version of Laravel

"Learn how to quickly and easily determine the version of Laravel you're using with a simple example."

How to Determine the Version of Laravel

Laravel is a powerful open-source web application framework that is used to develop web applications. It utilizes the Model-View-Controller (MVC) architectural pattern and provides different ways to determine the version of Laravel that is currently installed on your system.

The first way is to check the application's composer.json file. This file is located in the root directory of the application. Inside the file, you can find the version of the framework that is currently installed. For example:


{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.2.5",
        "laravel/framework": "^7.0"
    },
    "require-dev": {
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0"
    },
    ...
}

The version of Laravel in the example is ^7.0. This means that any version of Laravel between 7.0 and 7.99 is installed.

Another way to determine the version is to check the app/Providers/AppServiceProvider.php file. This file contains the version of the framework in the $version variable. For example:


namespace AppProviders;

use IlluminateSupportServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * The Laravel version.
     *
     * @var string
     */
    protected $version = '7.2.3';

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

The version of Laravel in the example is 7.2.3.

Finally, you can also check the application's artisan command. This command can be used to display the version of the framework that is currently installed. For example:


$ php artisan --version
Laravel Framework 7.2.3

The version of Laravel in the example is 7.2.3.

In conclusion, there are a few different ways to determine the version of Laravel that is currently installed on your system. You can check the composer.json file, the app/Providers/AppServiceProvider.php file, or the artisan command. With any of these methods, you can easily determine the version of Laravel that is installed on your system.

Answers (0)