/MobileDetectServiceProvider

A mobile detect ServiceProvider for Silex, based on Mobile-Detect library.

Primary LanguagePHPMIT LicenseMIT

MobileDetectServiceProvider

A mobile detect ServiceProvider for Silex, based on Mobile-Detect library.

Fetch

The recommended way to install MobileDetectServiceProvider is through composer.

Just create a composer.json file for your project:

{
    "require": {
        "jbinfo/mobile-detect-service-provider": "~1",
        "silex/silex": "~1"
    }
}

Register

use Silex\Application;
use Binfo\Silex\MobileDetectServiceProvider;

$app = new Application();

$app->register(new MobileDetectServiceProvider());

Usage

if ($app["mobile_detect"]->isMobile()) {
    echo "Mobile device";
    
} else {
    echo "Desktop device";
}
echo $app["mobile_detect"]->version('iPad');

For more informations check the website of Mobile-Detect library.

Bitdeli Badge