承接 torkashvand/laravel-minidevicedetector 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

torkashvand/laravel-minidevicedetector

Composer 安装命令:

composer require 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.

README 文档

README

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.

This project has forked from django-minidetector, and modified for PHP.

The following is added to the request:

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.

Touch Device

$request->isTouchDevice

true for devices that use touch events.

Wide Device

$request->isWideDevice

true for devices that are wider than a common mobile phone. This covers tablets and desktop browsers.

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.

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

Other Attributes

$request->isWebkit

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

If you only have certain route that need the distinction all you need to do is adding the middleware to it:

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

Of course this middleware can also be applied to a bunch of routes:

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

   //all the controllers of your admin section
   ...
   
});

Install

You can install the package via composer:

$ composer require torkashvand/laravel-minidevicedetector

Next, you must install the service provider:

// config/app.php
'providers' => [
    ...
    Torkashvand\MiniDeviceDetector\MiniDeviceDetectorServiceProvider::class,
];

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

//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.

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.

Contributing

Please see CONTRIBUTING for details.

License

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

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固