2017 © Pedro Peláez
 

library laravel-minidevicedetector

A middleware that adds attributes to your request object that describe the users browser. This will let you fine tune the templates or code to use based on the traits of the browser.

image

torkashvand/laravel-minidevicedetector

A middleware that adds attributes to your request object that describe the users browser. This will let you fine tune the templates or code to use based on the traits of the browser.

  • Friday, December 23, 2016
  • by torkashvand
  • Repository
  • 1 Watchers
  • 1 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

About

This middleware package adds attributes to your request object that describe the users browser. This will let you fine tune the templates or code to use based on the traits of the browser., (*1)

This project has forked from django-minidetector, and modified for PHP., (*2)

The following is added to the request:, (*3)

Simple Device

$request->isSimpleDevice

true for all non-desktop devices (browsers) without "modern" CSS and JS support. This includes non "smart" phones and simpler browsers like those found on game consoles and the kindle., (*4)

Touch Device

$request->isTouchDevice

true for devices that use touch events., (*5)

Wide Device

$request->isWideDevice

true for devices that are wider than a common mobile phone. This covers tablets and desktop browsers., (*6)

Device Type

    $request->isSimpleDevice
    $request->isTouchDevice
    $request->isWideDevice
    $request->mobile
    $request->isWebkit
    $request->isIOSDevice
    $request->isAndroidDevice
    $request->isWebOSDevice
    $request->isWindowsPhoneDevice

true if the device is part of the given platform., (*7)

These give more granular information about modern smart devices. This is helpful if you want to target features to a specific device type., (*8)

Other Attributes

$request->isWebkit

true if the browser is webkit (desktop or mobile.), (*9)

If you only have certain route that need the distinction all you need to do is adding the middleware to it:, (*10)

Route::get('/need-destination', [
   'middleware'=> 'mini-detector:viewNeedDestination',
   'uses' => 'NeedDestinationController@index',
]);

Of course this middleware can also be applied to a bunch of routes:, (*11)

Route::group(['prefix' => 'admin', 'middleware' => 'mini-detector:viewAdmin'], function() {

   //all the controllers of your admin section
   ...

});

Install

You can install the package via composer: ``` bash $ composer require torkashvand/laravel-minidevicedetector, (*12)


Next, you must install the service provider: ```php // config/app.php 'providers' => [ ... Torkashvand\MiniDeviceDetector\MiniDeviceDetectorServiceProvider::class, ];

Next, the \Torkashvand\MiniDeviceDetector\Middleware\MiniDeviceDetector::class-middleware must be registered in the kernel:, (*13)

//app/Http/Kernel.php
protected $routeMiddleware = [
  ...
  'mini-detector' => \Torkashvand\MiniDeviceDetector\Middleware\MiniDeviceDetector::class,
];

Naming the middleware mini-detector is just a suggestion. You can give it any name you'd like., (*14)

Usage

Detecting device type


Route::get('/need-destination', ['middleware'=> 'mini-detector','uses' => 'NeedToDetectController@show']);

Change log

Please see CHANGELOG for more information what has changed recently., (*15)

Contributing

Please see CONTRIBUTING for details., (*16)

License

The MIT License (MIT). Please see License File for more information., (*17)

The Versions

23/12 2016

dev-master

9999999-dev https://github.com/torkashvand/laravel-minidevicedetector

A middleware that adds attributes to your request object that describe the users browser. This will let you fine tune the templates or code to use based on the traits of the browser.

  Sources   Download

MIT

by Mohammad Torkashvand

laravel middleware torkashvand laravel-minidevicedetector devicedetector

23/12 2016

v1.0.0

1.0.0.0 https://github.com/torkashvand/laravel-minidevicedetector

A middleware that adds attributes to your request object that describe the users browser. This will let you fine tune the templates or code to use based on the traits of the browser.

  Sources   Download

MIT

by Mohammad Torkashvand

laravel middleware torkashvand laravel-minidevicedetector devicedetector

23/12 2016

dev-develop

dev-develop https://github.com/torkashvand/laravel-minidevicedetector

A middleware that adds attributes to your request object that describe the users browser. This will let you fine tune the templates or code to use based on the traits of the browser.

  Sources   Download

MIT

by Mohammad Torkashvand

laravel middleware torkashvand laravel-minidevicedetector devicedetector