How can I echo the version of the current Laravel version in php using the view?

旧巷老猫 提交于 2019-12-02 15:42:11
YeHtunZ

This is the way how to see laravel version in command explorer:

php artisan --version
$laravel = app();
$version = $laravel::VERSION;

Here is an easiest way to check it manually from the folder

Go to project folder

D:\xampp\htdocs\your-project-folder\vendor\laravel\framework\src\Illuminate\Foundation\Application.php

const VERSION = '5.2.45'; //version of laravel

This is the another way to check it.

If you don't want to check using this command php artisan --version

In Laravel's Blade templates:

{{ App::VERSION() }}

Note that this is tested in 5.3x

There are different ways of coding, I found multiple ways to current version find in Laravel

View current Laravel version through Blade Templates, there are many ways:

First way

{{ App::VERSION() }} 

Second way

<?php
     echo $app::VERSION;
?>

Third way

<?php
  $laravel = app();
  echo $laravel::VERSION;
?>

Also, the Laravel version installed can be checked in the command line using the following command :

php artisan --version
global $app;
echo $app::VERSION;

you can use this code in routing file of your laravell installation

 $app->get('/', function () use ($app) {
return $app->version();
}); 

On view you will get installed version of laravell.

Displaying Your Current Laravel Version

You may also view the current version of your Laravel installation using the --version option:

php artisan --version

Another way that works throughout your app - Blade templates or otherwise - is to use:

app()->version()
Tanay Chatterjee

Only for a specific Project Folder to know the Laravel version of that project on CLI

$  php artisan --version

remove $ while copying only for representation purpose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!