如何使用视图在 php 中回显当前 Laravel 版本的版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27153630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:12:48  来源:igfitidea点击:

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

phplaravelversion

提问by Dirk Jan

I don't want to check my Laravel version in the command prompt (php artisan --version), but in the view itself.

我不想在命令提示符 ( php artisan --version) 中检查我的 Laravel 版本,而是在视图本身中。

Like this:

像这样:

<?php
  $laravel_version = /*laravel version check code*/;
?>

In the view:

在视图中:

{{ $laravel_version }}

Do anyone know how I can do that? Maybe it isn't possible..?

有谁知道我该怎么做?也许这是不可能的..?

回答by YeHtunZ

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

这是如何在命令资源管理器中查看 Laravel 版本的方法:

php artisan --version

回答by sradha

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

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

const VERSION = '5.2.45'; //version of laravel enter image description here

常量版本 = '5.2.45'; //laravel的版本 在此处输入图片说明

This is the another way to check it.

这是检查它的另一种方法。

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

如果您不想使用此命令进行检查php artisan --version

回答by fire

$laravel = app();
$version = $laravel::VERSION;

回答by Matija Boban

In Laravel's Blade templates:

在 Laravel 的 Blade 模板中:

{{ App::VERSION() }}

Note that this is tested in 5.3x

请注意,这是在 5.3x 中测试的

回答by Udhav Sarvaiya

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

有不同的编码方式,我在 Laravel 中找到了多种查找当前版本的方法

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

通过Blade Templates查看当前的 Laravel 版本,有多种方式:

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 :

此外,可以使用以下命令在命令行中检查安装的 Laravel 版本:

php artisan --version

回答by nikksan

global $app;
echo $app::VERSION;

回答by Abhi

  • ubunut 16.04
  • php 7.0.33
  • Laravel Framework 5.5.48

    php artisan --version
    

    Artisan-Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. It is driven by the powerful Symfony Console component.

  • Ubuntu 16.04
  • php 7.0.33
  • Laravel 框架 5.5.48

    php artisan --version
    

    Artisan-Artisan 是 Laravel 附带的命令行界面的名称。它提供了许多有用的命令供您在开发应用程序时使用。它由强大的 Symfony Console 组件驱动。

for more-

更多-

    php artisan list

回答by Rasheduzzaman

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

通过 Blade Templates 查看当前的 Laravel 版本,有多种方式:

1st way to show,

第一种展示方式,

 {{ App::VERSION() }}

2nd way,

第二种方式,

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

3rd way,

第三种方式,

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

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

可以使用以下命令在命令行中检查安装的 Laravel 版本:

    php artisan --version

回答by gaurav malik

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

您可以在 Laravell 安装的路由文件中使用此代码

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

On view you will get installed version of laravell.

在视图中,您将获得已安装的 laravel 版本。

回答by Rafiqul Islam

Displaying Your Current Laravel Version

显示你当前的 Laravel 版本

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

您还可以使用--version选项查看 Laravel 安装的当前版本:

php artisan --version