Check Laravel Version

Sometimes you may need to check which version of the Laravel framework you're using. It can be useful when installing PHP packages. This tutorial shows how to check Laravel version.

1. 'version' option

Laravel version can be determined by using artisan command with version option.

php artisan --version

Output example:

Laravel Framework 9.4.1

2. 'VERSION' constant

The Application class has VERSION constant which stores Laravel version.

test.php

<?php

use Illuminate\Foundation\Application;

require_once __DIR__.'/vendor/autoload.php';

echo Application::VERSION;

3. 'app' helper

If you want to print Laravel version in the application, use the app helper.

app/Http/Controllers/TestController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Response;

class TestController extends Controller
{
    public function index(): Response
    {
        return new Response(app()->version());
    }
}

Leave a Comment

Your email address will not be published.