Sometimes you need to know the exact version of your Laravel application. Luckily, there are multiple ways how to check the version and you can use the one that fits your needs in a specific situation.
But first, check out Tinkerwell and join more than 12,000 Laravel developers who use Tinkerwell to run code in the context of their Laravel applications without creating
/test
routes.
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
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.
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(); ?>";});
“I use Tinkerwell every single day and have 25 tabs open at any one time. It’s the essential tool for Laravel developers”
Jack Ellis
Co-founder of Fathom Analytics
“I like the flexibility to run code outside of IDE to "quick test" functionality. The ability to run code remotely on servers to run quick reports or interrogate the database instead of using DataGrip or other IDEs.”Oliver Sarfas
Laravel Consultant
The must-have companion to your favorite IDE. Quickly iterate on PHP code within the context of your web application.
Buy now Learn more