Home > PHP Framework > Laravel > How to check Laravel version (three methods)

How to check Laravel version (three methods)

PHPz
Release: 2023-04-06 19:04:48
Original
5155 people have browsed it

Laravel is a widely used PHP framework that allows us to build web applications more efficiently. As we all know, Laravel is a framework that supports continuous updates, and new versions are often launched.

When using Laravel, it is very important to know which version you are using. In this article, we will learn how to check Laravel version.

View the Laravel version through the console

First, we can run the following command in the terminal to view the Laravel version:

php artisan --version
Copy after login

This command will display the Laravel version in the console The information is as follows:

Laravel Framework X.X.X
Copy after login

This shows that the Laravel version we are currently using is X.X.X. We can quickly check Laravel's current version information in this way.

View Laravel version through composer.json file

Another way to check Laravel version is to view the composer.json file.

We can use the following command to open the composer.json file in the root directory of the Laravel project:

nano composer.json
Copy after login

In the opened file, we can find the version of Laravel , as shown below:

"require": {
    "php": "^7.3|^8.0.0",
    "fideloper/proxy": "^4.2",
    "laravel/framework": "^8.0"
},
Copy after login

In this example, we can see that the version of Laravel is 8.0. By looking at the composer.json file, we can understand the Laravel version currently in use as well as the PHP version and other dependencies it depends on.

Check the Laravel version through Http request

Finally, we can also check the Laravel version through http request.

We can add the following route in the code:

Route::get('/version', function () {
    return response()->json(['version' => app()->version()]);
});
Copy after login

Then we visit http://your-app.com/version in the browser, which will return A JSON response containing the current Laravel version.

By adding this route, we can easily query Laravel's version information through HTTP requests.

Summary

In this article, we learned how to check the Laravel version through the terminal, composer.json file, and HTTP request. Through these methods, we can easily understand the Laravel version information used by the current project, allowing us to develop our applications more efficiently.

The above is the detailed content of How to check Laravel version (three methods). For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template