Asked : Nov 17
Viewed : 51 times
How to get the Laravel version and where is it defined?
Is the Laravel version is defined inside my application directory or somewhere in the global server-side directory?
The goal is to investigate, who (of us) has changed the Laravel version on our site. Could it be changed by GitHub repository edition only? Or server write access was also required?
Nov 17
Just run following command from your console or terminal to get Laravel version of your project.
php artisan --version
or php artisan -v
answered Dec 02
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 sample 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 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(); ?>";
});
answered Dec 30