padawanTony
padawanTony

Reputation: 1359

Device Detection With PHP

I am working in PHP, specifically Laravel.

I want to show different views according to how big the user's screen is (ex: mobile or pc). In simple words, here is what I want my routing to look like:

if (device == mobile){
    Route::view('/', 'mobile_ui');
} else {
    Route::view('/', 'desktop_ui');
}

Let me clarify that this question is not about responsive design. I just want to use two different UI templates; one for the mobile and one for the desktop.


EDIT: As pointed out by @rickdenhaan in the comments, the answer to this question can be found here: Simplest way to detect a mobile device

Upvotes: 0

Views: 6487

Answers (1)

Maciek
Maciek

Reputation: 88

Use js for that and make redirect to different route with different layout. Or you can check $_SERVER['HTTP_USER_AGENT'] variable and detect mobile device by that

Edit: I did additional digging and found this: https://github.com/serbanghita/Mobile-Detect It should solve your issue completly :)

Upvotes: 0

Related Questions