How to check Laravel version

Categories: Laravel

How to check the Laravel version of your application

 

 

Sometime you need to know your Laravel version, luckily here are some ways to know your Laravel version

 

Check Laravel version via CLI

You can check the Laravel version via an artisan command. This is the easiest way if you use the terminal regularly and are familiar with artisan commands in general. You can get the version via the command:

 

php artisan --version

 

Get the Laravel version the app() helper

Every Laravel release has the version of the framework as constant in the Application.php file. You can access this constant via the app() helper.

 

app()->version()

If you don't want to create a /test route to get the version, you can use php artisan tinker to get into the tinker REPL and run it from there. If you use Tinkerwell, you can run the code directly in Tinkerwell and this is what we are doing most of the time. It works on local applications and via SSH and checking the Laravel version is a breeze.

 

Displaying the Laravel version in a Blade template

If you want to check the current Laravel version but don't run code every time, you can also display the version in your admin system via Blade. You can either display it via the app() helper or create a Blade macro for it. Displaying via the helper works with a simple output:

The current Laravel version is {{ app()->version() }}

If you check the Laravel version often and need it in multiple views, it could be useful to have a Blade directive for it. Blade directives are placed in the boot method of the AppServiceProvider of your application and you can add this code to simply display the version in Blade templates with @laravelVersion

 

Blade::directive('laravelVersion', function () {

    return "<?php echo app()->version(); ?>";

});

Top Blogs
What is Laravel and its use Published at:- Some Laravel Features Published at:- Laravel Interview Question Answer for Freshers and Experienced Published at:- How to check Laravel version Published at:- Spring vs Laravel : A detail Comparison between Laravel vs Spring Framework Published at:- Powerful New Web Development Features in Laravel 8 Published at:- Laravel – A Trending PHP Framework lets know about this Published at:- Advantages of Laravel Published at:- Laravel Framework Architecture and CodeIgniter Published at:- The Laravel History and Its works framework develop Published at:- About composer in Laravel and Artisan Published at:- Masters of Laravel Structure for web advancement Published at:- Professionals Of Laravel Framework for Internet Development Published at:- Which is Best Laravel or PHP Published at:- Laravel And Vue JS Strong Mix for Web Improvement Published at:- PHP Structures Laravel or Symfony Published at:- What can be the distinctions between WordPress and Headless Laravel CMS Published at:-
R4R.co.in Team
The content on R4R is created by expert teams.