serbanghita / Mobile-Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

Home Page:http://mobiledetect.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

composer installation and usage

tete2soja opened this issue · comments

Hello,

I used composer to install the package but I can't load and use the class in my PHP code. I didn't find any example to use it with composer.
Can you give the correct use to use or class name. I tried with this ones:

require 'vendor/autoload.php';

use Detection\MobileDetect;
$mobileDetect = new MobileDetect();

use Detection\MobileDetect;
$mobileDetect = new MobileDetect;

use MobileDetect\MobileDetect;
$mobileDetect = new MobileDetect;

use MobileDetect\MobileDetect;
$mobileDetect = new MobileDetect();

And always get this error: Fatal error: Uncaught Error: Class 'Mobile_Detect' not found in /var/www/html/header.php:17 Stack trace: #0 /var/www/html/index.php(1): require_once() #1 {main} thrown in /var/www/html/header.php on line 17

Thanks in advance!

Solve on my own.

use Detection\MobileDetect;
$detect = new Mobile_Detect();