Skip to content

nikolaposa/MobileDetectModule

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

MobileDetectModule

Build Status Code Quality Code Coverage Latest Version

ZF module which facilitates integration of a PHP MobileDetect library (http://mobiledetect.net).

Installation

The preferred method of installation is via Composer. Run the following command to install the latest version of a package and add it to your project's composer.json:

composer require nikolaposa/mobile-detect-module

Enable the module in your application.config.php:

<?php
return [
    'modules' => [
        // ...
        'MobileDetectModule',
    ],
    // ...
];

Features

  • Factory for creating MobileDetect service
  • View helper and controller plugin for providing easier access to the MobileDetect service

Usage

MobileDetect service

The actual Mobile_Detect class instance will be available under the MobileDetect service. Refer to the Mobile Detect project documenation for more information about its features.

$mobileDetect = $container->get('MobileDetect'); //Detection\MobileDetect instance

if ($mobileDetect->isMobile()) {
    //do something
}

View helper

View helper - mobileDetect is available for providing access to the MobileDetect service on the view layer:

echo $this->mobileDetect()->version('Android');

Controller plugin

Controller plugin - mobileDetect is available for providing access to the MobileDetect service on the controller layer:

if ($this->mobileDetect()->isTablet()) {
    //do something
}

Credits

License

Released under MIT License - see the License File for details.

About

ZF Module which facilitates integration of a PHP MobileDetect library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages