Laravel

How to Check the Laravel Version

Laravel is a popular PHP framework known for its elegant syntax and robust features. If you're working with a Laravel project and need to determine the version you're using, there are a few simple methods you can try.

The easiest way to check the Laravel version is by using the command line. Open your terminal or command prompt and navigate to the root folder of your Laravel project. Then, run the following command:

php artisan --version

This command will display the Laravel version installed in your project. Make sure you have PHP installed and added to your system's PATH variable for this method to work.

If you have access to the project files, you can check the Laravel version directly from the framework files. Locate the composer.json file in your project's root folder and open it in a text editor. Look for the laravel/framework package entry, which should contain the version information. It will look like this:

"require": {
    "php": "^7.3|^8.0",
    "laravel/framework": "^10.0",
    ...
},

In this example, the Laravel version is specified as 10.0. Note that this method requires access to the project files.

If you have a running Laravel application, you can check the version by creating a simple route that displays the Laravel version. Open the routes/web.php file in your project and add the following route:

Route::get('/laravel-version', function () {
    $laravelVersion = app()->version();
    return "Laravel Version: " . $laravelVersion;
});

Save the file and access the /laravel-version URL in your web browser. You should see the Laravel version displayed on the page. These are three straightforward methods for checking the Laravel version. By using the command line, inspecting the composer.json file, or creating a custom route, you can quickly find the version of Laravel being used in your project. Knowing the Laravel version is crucial for compatibility and ensuring you have access to the latest features and fixes.

Read more Articles