1. Go to this page and download the library: Download mimmi20/wurfl 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/ */
mimmi20 / wurfl example snippets
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*
* change this to pass to your project settings
*/
chdir(dirname(__DIR__));
sourcesDir . '/storage/cache';
// Create WURFL Configuration
$wurflConfig = new \Wurfl\Configuration\InMemoryConfig();
// Set location of the WURFL File
$wurflConfig->wurflFile($resourcesDir . '/wurfl.zip');
/*
* Set the match mode for the API
*
* It is recommended to use the defined class constants instead of their
* string values:
*
* \Wurfl\Configuration\Config::MATCH_MODE_PERFORMANCE
* \Wurfl\Configuration\Config::MATCH_MODE_ACCURACY
*/
$wurflConfig->matchMode(\Wurfl\Configuration\Config::MATCH_MODE_PERFORMANCE);
// Setup WURFL Persistence
$wurflConfig->persistence(
'file',
array(\Wurfl\Configuration\Config::DIR => $persistenceDir)
);
// Setup Caching
$wurflConfig->cache(
'file',
array(
\Wurfl\Configuration\Config::DIR => $cacheDir,
\Wurfl\Configuration\Config::EXPIRATION => 36000
)
);
// Create the cache instance from the configuration
$cacheStorage = Storage\Factory::create($wurflConfig->cache);
// Create the persistent cache instance from the configuration
$persistenceStorage = Storage\Factory::create($wurflConfig->persistence);
// Create a WURFL Manager from the WURFL Configuration
$wurflManager = new \Wurfl\Manager($wurflConfig, $persistenceStorage, $cacheStorage);
// Create WURFL Configuration
$wurflConfig = new \Wurfl\Configuration\InMemoryConfig();
// Set location of the WURFL File
$wurflConfig->wurflFile($resourcesDir . '/wurfl.zip');
/*
* Set the match mode for the API
*
* It is recommended to use the defined class constants instead of their
* string values:
*
* \Wurfl\Configuration\Config::MATCH_MODE_PERFORMANCE
* \Wurfl\Configuration\Config::MATCH_MODE_ACCURACY
*/
$wurflConfig->matchMode(\Wurfl\Configuration\Config::MATCH_MODE_PERFORMANCE);
// Setup WURFL Persistence
$wurflConfig->persistence(
'file',
array(\Wurfl\Configuration\Config::DIR => $persistenceDir)
);
// Setup Caching
$wurflConfig->cache(
'file',
array(
\Wurfl\Configuration\Config::DIR => $cacheDir,
\Wurfl\Configuration\Config::EXPIRATION => 36000
)
);