# How to use (composer)

```
composer require mobiledetect/mobiledetectlib
```

```json
// composer.json
{
    "require": {
        "mobiledetect/mobiledetectlib": "4.8.09" // Change to the lastest version.
    }
}
```

```php
// your_script.php
// (optional) You're app is probably already using composer autoloader.
require __DIR__ . '/vendor/autoload.php';

// (mandatory)
use Detection\MobileDetect;
$detect = new MobileDetect();

// (optional) By default the Mobile Detect library auto-detects the HTTP headers from $_SERVER global variable.
$detect->setUserAgent('Mozilla/5.0 (iPad; CPU OS 14_7 like Mac OS X) ...');

// Use whatever methods you want.
$isMobile = $detect->isMobile();
$isTablet = $detect->isTablet();

var_dump($isMobile);
var_dump($isTablet);

var_dump($detect); // debug
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mobiledetect.net/home/usage-composer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
