PHP code example of s1syphos / kirby-device

1. Go to this page and download the library: Download s1syphos/kirby-device library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

s1syphos / kirby-device example snippets


// Configuration Methods
setCache()
setYamlParser()
discardBotInformation()
skipBotDetection()

// General Device Type Methods
isBot()
isMobile()
isDesktop()
isTouchEnabled() // win8 tablets only

// General Client Type Methods
getBot() // array
getClient() // array | optionally string, eg getClient('version'))
getOs() // array | optionally string, eg getOs('version')
getDevice()
getDeviceName()
getBrand()
getBrandName()
getModel()
getUserAgent()

// Specific Device Type Methods
isSmartphone()
isFeaturePhone()
isTablet()
isPhablet()
isConsole()
isPortableMediaPlayer()
isCarBrowser()
isTV()
isSmartDisplay()
isCamera()

// Specific Client Type Methods
isBrowser()
isFeedReader()
isMobileApp()
isPIM()
isLibrary()
isMediaPlayer()

if (device()->isMobile()) {
  // Your code here.
}

if (device()->isTablet()) {
  // Your code here.
}

if(device()->isDesktop() || device()->isTablet()) {
    // Your desktop & tablet code here.
}

// Get mobile device information
$brand = device()->getBrandName(); // eg 'Apple'
$model = device()->getModel(); // eg 'iPhone'

// Custom function detecting Chrome browser
function isChrome() {
  return device()->getClient('name') == 'Chrome' ? true : false;
}