A mobile detect ServiceProvider for Silex, based on Mobile-Detect library.
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"
}
}
use Silex\Application;
use Binfo\Silex\MobileDetectServiceProvider;
$app = new Application();
$app->register(new MobileDetectServiceProvider());
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.