PHPackages                             zguillez/slim-mobile-detect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. zguillez/slim-mobile-detect

ActiveLibrary[Framework](/categories/framework)

zguillez/slim-mobile-detect
===========================

Implements Mobile-Detect lib for Slim Framework app

1.0.0(10y ago)1990.0k—1%4[1 issues](https://github.com/zguillez/slim-mobile-detect/issues)MITPHP

Since Mar 8Pushed 5y ago2 watchersCompare

[ Source](https://github.com/zguillez/slim-mobile-detect)[ Packagist](https://packagist.org/packages/zguillez/slim-mobile-detect)[ RSS](/packages/zguillez-slim-mobile-detect/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

Slim-Mobile-Detect
==================

[](#slim-mobile-detect)

[![Analytics](https://camo.githubusercontent.com/7aea965f6dfc9079ee0704709baff01872b09590c9ac6895c58017e6c62eb858/68747470733a2f2f67612d626561636f6e2e61707073706f742e636f6d2f55412d313132353231372d33302f7a6775696c6c657a2f736c696d2d6d6f62696c652d6465746563743f706978656c)](https://github.com/igrigorik/ga-beacon)[![License](https://camo.githubusercontent.com/e498eead712d82d9ee1af0a4850acd2e46ea48c48fb9ce5a3d2ab64f28f95b34/687474703a2f2f696d672e736869656c64732e696f2f3a6c6963656e73652d6d69742d626c75652e737667)](http://doge.mit-license.org)[![Installs](https://camo.githubusercontent.com/2d9304bc82470d12cd24c14835dfa0a725a7e819794a22ca54f22941e911f9a5/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f64742f736c696d2d6d6f62696c652d6465746563742e737667)](https://coveralls.io/r/zguillez/slim-mobile-detect)[![Join the chat at https://gitter.im/zguillez/slim-mobile-detect](https://camo.githubusercontent.com/2b576fb84dfe36f8bf17788e1a478059419d4345e651bf5cf7c8c57495c90df5/68747470733a2f2f6261646765732e6769747465722e696d2f7a6775696c6c657a2f736c696d2d6d6f62696c652d6465746563742e737667)](https://gitter.im/zguillez/slim-mobile-detect?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

> [Zguillez](https://zguillez.io) | Guillermo de la Iglesia

[![ko-fi](https://camo.githubusercontent.com/1fedf764fa06114b797ee53e7506df10880abed6766f854202d758df1707969d/68747470733a2f2f7777772e6b6f2d66692e636f6d2f696d672f676974687562627574746f6e5f736d2e737667)](https://ko-fi.com/Q5Q4329UT)

Implements [Mobile-Detect](https://github.com/serbanghita/Mobile-Detect) lib for Response's write on [Slim Framework](http://www.slimframework.com/) App
--------------------------------------------------------------------------------------------------------------------------------------------------------

[](#implements-mobile-detect-lib-for-responses-write-on-slim-framework-app)

[![](https://camo.githubusercontent.com/c76a63e16c7bc3ebf76cb8897d456a6aacc63053/687474703a2f2f64656d6f2e6d6f62696c656465746563742e6e65742f6c6f676f2d6769746875622e706e67)](https://camo.githubusercontent.com/c76a63e16c7bc3ebf76cb8897d456a6aacc63053/687474703a2f2f64656d6f2e6d6f62696c656465746563742e6e65742f6c6f676f2d6769746875622e706e67)

Getting Started
===============

[](#getting-started)

### Add package to composer.json

[](#add-package-to-composerjson)

`composer require zguillez/slim-mobile-detect`

```
// composer.json
{
  "require": {
    "slim/slim": "^3.0",
    "zguillez/slim-mobile-detect": "^1.0.0"
  }
}

```

### Override $request and $response objects on app routes

[](#override-request-and-response-objects-on-app-routes)

```
$app->get('/hello/{name}', function ($request, $response, $args) {
	$request  = new Slim\Http\MobileRequest($request);
	$response = new Slim\Http\MobileResponse($response);

	// ...
});

```

Usage
=====

[](#usage)

### On Request object:

[](#on-request-object)

```
$request->isMobile()

```

Return *true* on **mobile devices** calls

```
$request->isTablet()

```

Return *true* on mobile **tablet** (no phones) calls

```
$request->isPhone()

```

Return *true* on mobile **phone** (no tablets) calls

```
$request->isiOS()

```

Return *true* on mobile with **iOS** calls

```
$request->isAndroidOS()

```

Return *true* on mobile with **Android** calls

### On Response object:

[](#on-response-object)

```
$response->writeDesktop($data)

```

Write the response only on **desktop** calls

```
$response->writeMobile($data)

```

Write the response only on **mobile** calls

```
$response->writePhone($data)

```

Write the response only on mobile **phone** (no tablets) calls

```
$response->writeTablet($data)

```

Write the response only on **tablet** (no phones) calls

```
$response->writeIOS($data)

```

Write the response only on **iOS** calls

```
$response->writeAndroid($data)

```

Write the response only on **Android** calls

Example:
========

[](#example)

```
