Esempio n. 1
0
/**
 * 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;
    $mobileDetect = new \Mobile_Detect();
    /**
     * Check for mobile devices, that are not tables. We want phones only.
     * If you need ALL mobile devices use this:   if($mobileDetect->isMobile())
Esempio n. 2
0
 public function testLogWithMonolog()
 {
     $pc = new PageCache();
     $pc->enableLog();
     $pc->setLogFilePath(vfsStream::url('tmpdir') . '/log.txt');
     //internal logger, should be ignored
     $logger = new Logger('PageCache');
     $logger->pushHandler(new StreamHandler(vfsStream::url('tmpdir') . '/monolog.log', Logger::DEBUG));
     $pc->setLogger($logger);
     $pc->init();
     ob_end_flush();
     $this->assertContains('PageCache\\PageCache::init', file_get_contents(vfsStream::url('tmpdir') . '/monolog.log'));
     $this->assertFalse(file_exists(vfsStream::url('tmpdir') . '/log.txt'));
 }