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.
First, we can run the following command in the terminal to view the Laravel version:
php artisan --version
This command will display the Laravel version in the console The information is as follows:
Laravel Framework X.X.X
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.
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
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" },
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.
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()]); });
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.
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!