/**
  * Constructor
  * Validate that the Zend Platform is loaded and licensed
  *
  * @param array $options associative array of options
  */
 public function __construct($options = array())
 {
     if (!function_exists('accelerator_license_info')) {
         Zend_Cache::throwException('The Zend Platform extension must be loaded for using this backend !');
     }
     if (!function_exists('accelerator_get_configuration')) {
         $licenseInfo = accelerator_license_info();
         Zend_Cache::throwException('The Zend Platform extension is not loaded correctly: ' . $licenseInfo['failure_reason']);
     }
     $accConf = accelerator_get_configuration();
     if (@(!$accConf['output_cache_licensed'])) {
         Zend_Cache::throwException('The Zend Platform extension does not have the proper license to use content caching features');
     }
     if (@(!$accConf['output_cache_enabled'])) {
         Zend_Cache::throwException('The Zend Platform content caching feature must be enabled for using this backend, set the \'zend_accelerator.output_cache_enabled\' directive to On !');
     }
     if (!is_writable($accConf['output_cache_dir'])) {
         Zend_Cache::throwException('The cache copies directory \'' . ini_get('zend_accelerator.output_cache_dir') . '\' must be writable !');
     }
     if (!is_array($options)) {
         Zend_Cache::throwException('Options parameter must be an array');
     }
     while (list($name, $value) = each($options)) {
         $this->setOption($name, $value);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     // This is needed to support the PHP 5.5 opcache as well as the old ZendOptimizer+-extension.
     if (function_exists('opcache_get_status')) {
         $status = opcache_get_status();
         $config = opcache_get_configuration();
         $version = $config['version']['opcache_product_name'] . ' ' . $config['version']['version'];
         $stats = $status['opcache_statistics'];
         $hitrate = $stats['opcache_hit_rate'];
     } elseif (function_exists('accelerator_get_status')) {
         $status = accelerator_get_status();
         $config = accelerator_get_configuration();
         $version = $config['version']['accelerator_product_name'] . ' ' . $config['version']['version'];
         $stats = $status['accelerator_statistics'];
         $hitrate = $stats['accelerator_hit_rate'];
     }
     $filelist = array();
     if ($this->showFilelist) {
         foreach ($status['scripts'] as $key => $data) {
             $filelist[$key] = $data;
             $filelist[$key]['name'] = basename($key);
         }
     }
     // unset unneeded filelist to lower memory-usage
     unset($status['scripts']);
     $this->data = array('version' => $version, 'ini' => $config['directives'], 'filelist' => $filelist, 'status' => $status, 'stats' => $stats, 'hitrate' => $hitrate);
 }
Example #3
0
 /**
  * Validate that the Zend Platform is loaded and licensed.
  *
  * @param   array  $parameters    Parameters.
  * @return  void
  * @throws  \Hoa\Cache\Exception
  */
 public function __construct(array $parameters = [])
 {
     if (!function_exists('accelerator_license_info')) {
         throw new Cache\Exception('The Zend Platform extension must be loaded to use this backend.', 0);
     }
     if (!function_exists('accelerator_get_configuration')) {
         $licenseInfos = accelerator_license_info();
         throw new Cache\Exception('The Zend Platform extension is not loaded correctly: %s.', 1, $licenseInfos['failure_reason']);
     }
     $configurations = accelerator_get_configuration();
     if (@(!$configurations['output_cache_licensed'])) {
         throw new Cache\Exception('The Zend Platform extension does not have the proper license ' . 'to use content caching features.', 2);
     }
     if (@(!$configurations['output_cache_enabled'])) {
         throw new Cache\Exception('The Zend Platform content caching feature must be enabled to ' . 'use this backend, set the ' . 'zend_accelerator.output_cache_enabled directive to on.', 3);
     }
     if (!is_writable($configuration['output_cache_dir'])) {
         throw new Cache\Exception('The cache copies directory %s must be writable.', 4, $configuration['output_cache_dir']);
     }
     parent::__construct($parameters);
     return;
 }