How to Get Browser Name, Device, OS Version in Laravel?
In this tutorial, you’ll learn how to find out the name of the web browser, device, and operating system version that a user is using while browsing your website. We’ll be using a package called jenssegers/agent in Laravel to achieve this.
To install the jenssegers/agent package in your Laravel app, simply enter the following command in your terminal.
If you want to find out the browser name, device, and operating system version of your website visitors in Laravel, you can use the jenssegers/agent package. Here’s how to do it:
- Open up your terminal and navigate to your Laravel project directory.
- Enter the following command to install the jenssegers/agent package:
- Once the package is installed, open up the file where you want to retrieve the information (e.g., a controller or a view).
- Import the Agent facade at the top of your file by adding the following line:
- Now you can use the Agent facade to retrieve the browser name, device, and operating system version like this:
- You can then use these variables to display the information in your view or perform other actions based on the user’s browser, device, or OS version.
That’s it! You now know how to get browser name, device, and OS version in Laravel using the jenssegers/agent package.
How to Get Browser Name, Device, OS Version in Laravel?
- Laravel Get Browser Name and Version
- Laravel Get Device Name
- Laravel Get OS Name
Laravel Get Browser Name and Version
Use the following code to find browser version by passing the result of Agent::browser() to the version() method: download the laravel setup click here
$browser = Agent::browser();
$version = Agent::version($browser);
Laravel Get Device Name
You can use the device() method that can find the user device name that the request was made from. is as follows:
$device = Agent::device();
Laravel Get OS Name
You can use the platform() method that can find the operating system that the request was made from. is as follows:
$platform = Agent::platform();
Conclusion
In this tutorial, you have learned how to get browser name, device, os version in laravel.
You May Also Like This

