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

PhpLaravelVersion

Php Problem Overview


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

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..?

Php Solutions


Solution 1 - Php

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

php artisan --version

Solution 2 - Php

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 enter image description here

This is the another way to check it.

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

Solution 3 - Php

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

Solution 4 - Php

In Laravel's Blade templates:

{{ App::VERSION() }}

Note that this is tested in 5.3x

Solution 5 - Php

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

Solution 6 - Php

global $app;
echo $app::VERSION;

Solution 7 - Php

  • 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.

for more-

    php artisan list

Solution 8 - Php

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.

Solution 9 - Php

Displaying Your Current Laravel Version

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

php artisan --version

Solution 10 - Php

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

app()->version()

Solution 11 - Php

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

Solution 12 - Php

One More way. Just go to the root directory of the project.
Hit below commands

php artisan tinker
App::VERSION()

Tinker is amazing.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDirk JanView Question on Stackoverflow
Solution 1 - PhpYe Htun ZView Answer on Stackoverflow
Solution 2 - PhpsradhaView Answer on Stackoverflow
Solution 3 - PhpfireView Answer on Stackoverflow
Solution 4 - PhpMatija BobanView Answer on Stackoverflow
Solution 5 - PhpUdhav SarvaiyaView Answer on Stackoverflow
Solution 6 - PhpnikksanView Answer on Stackoverflow
Solution 7 - PhpAbhiView Answer on Stackoverflow
Solution 8 - Phpgaurav malikView Answer on Stackoverflow
Solution 9 - PhpRafiqul IslamView Answer on Stackoverflow
Solution 10 - PhpScott CarpenterView Answer on Stackoverflow
Solution 11 - PhpTanay ChatterjeeView Answer on Stackoverflow
Solution 12 - PhpHV SharmaView Answer on Stackoverflow