示例#1
0
 public function testSetStrategyException()
 {
     $pc = new PageCache();
     try {
         $pc->setStrategy(new \stdClass());
         $this->expectException('PHPUnit_Framework_Error');
     } catch (\Throwable $e) {
         // echo '~~~~As expected PHP7 throws Throwable.';
     } catch (\Exception $e) {
         // echo '~~~~As expected PHP5 throws Exception.';
     }
 }
示例#2
0
 *                composer require mobiledetect/mobiledetectlib
 *                or whichever other way you prefer. mobiledetect is being suggested during PageCage install.
 *
 */
/**
 * Composer autoload, or use any other means
 */
require_once __DIR__ . '/../vendor/autoload.php';
use PageCache\PageCache;
use PageCache\Strategy\MobileStrategy;
/**
 * PageCache setup
 */
$config_file = __DIR__ . '/conf.php';
$cache = new PageCache($config_file);
$cache->setStrategy(new MobileStrategy());
//enable session support if needed, check demos and README for details
//uncomment for session support
//$cache->enableSession();
$cache->init();
/**
 * Mobile detect helper function for detecting mobile devices.
 * Tablets are excluded on purpose here, suit your own needs.
 *
 * Mobile_detect project URL: http://www.mobiletedect.net
 *                          : https://packagist.org/packages/mobiledetect/mobiledetectlib
 *
 */
function isMobileDevice()
{
    $mobileDetect = null;