Readytocode
  • Home
  • Laravel
  • PHP
  • React Js
  • Git
  • Server
Facebook X (Twitter) Instagram
Readytocode
  • Home
  • Laravel
  • PHP
  • React Js
  • Git
  • Server
Facebook X (Twitter) Instagram Pinterest LinkedIn Reddit
Readytocode
You are at:Home Laravel 9 – Get User Device, Browser and OS

Laravel

Laravel 9 – Get User Device, Browser and OS

JustinBy JustinJanuary 18, 2023Updated:January 23, 2023No Comments2 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Email




In this post, i will show you, How we can get user Devices like Desktops, Mobile, Tablets, browsers like Chrome, Firefox, etc, and OS like Linux, OS X, and Windows.

This will be required, we are creating a Project which you have to make according to Device or Browser, or OS platform

Step 1. Install Laravel
Step 2. Install Package (jenssegers/Agent)
Step 3. Create controller and Route
Step 4. Output
Step 5. Conclusion

Step 1. Install Laravel 

As you are looking this example, so definitely you already installed the laravel app, But still i am showing you how we can install.

composer create-project laravel/laravel PlatformFinder

 

Step 2. Install Package (jenssegers/Agent)

Now we will use jenssegers/agent package which will help us to Find all the details. Now use the below command to install this package.

composer require jenssegers/agent

 

Step 3. Create controller and Route

Now create a controller using the artisan command.

php artisan make:controller DeviceController

 

Now create the functions like below.

<?php

namespace App\Http\Controllers;
use Jenssegers\Agent\Facades\Agent;

use Illuminate\Http\Request;

class DeviceController extends Controller
{
    public function index()
    {
        $device = Agent::device();
        echo $device;
        
        $platform = Agent::platform();

        echo "<br>";
        echo $platform;
       
        $version = Agent::version($platform);
        echo "<br>";
        echo $version;

        echo "<br>";
        $browser = Agent::browser();
        echo $browser;
        
        echo "<br>";
        $browser_version = Agent::version($browser);
        echo $browser_version;

    }
}

Note- don’t forgot to import the package.
use Jenssegers\Agent\Facades\Agent;

Now open routes/web.php

use App\Http\Controllers\DeviceController;

Route::get("/device",[DeviceController::class,'index']);

Now this step done.

Step 4. Output

it’s simple just open run your project using artisan command and open the provide url
http://127.0.0.1:8000/device

Output find device and browser
Output find device, browser and OS

Step 5. Conclusion

Hopefully , this example will gives you some idea about, how we can use the use the client details. And if you are building a high scale web app, i am sure this will help you.
If you feel it’s helpful for you then, Like and share.

 

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Share 0

Like this:

Like Loading...

Related

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Justin
  • Website

Related Posts

How to Generate image from text with Laravel 10

May 16, 2023

Laravel 10 Restrict User Access

May 3, 2023

Laravel 10 Pagination Example

May 3, 2023

Comments are closed.

Featured Posts
  • Why meta tag is important for seo 1
    How to change react Page title, Page Description and some other meta Tag
    • August 4, 2023
  • 2
    How to Generate image from text with Laravel 10
    • May 16, 2023
  • Laravel 10 Restrict User Access 3
    Laravel 10 Restrict User Access
    • May 3, 2023
  • Laravel 10 Pagination Example 4
    Laravel 10 Pagination Example
    • May 3, 2023
  • install Steam on Ubuntu 5
    How to install Steam on Ubuntu 22.04 step by step
    • April 20, 2023



Readytocode
Facebook X (Twitter) Instagram Pinterest
  • About Us
  • Privacy Policy
© 2025 ReadyToCode.

Type above and press Enter to search. Press Esc to cancel.

%d