简体   繁体   中英

PHP Cache Lite PEAR

please is there someone who knows how to install and use PEAR Cache Lite? I try to make this little code but it returned an error:

Class 'PEAR' not found in /var/www/vhosts...../Cache/Lite.php

knowing that I have pear install on my dedicated server (Kernel red hat kimsufi)

// on fait appel a notre librairie PEAR
set_include_path(get_include_path() . "usr/share/pear");

// On charge Cache_Lite
require_once('../Cache/Lite/Output.php');

// On fixe un identifiant pour la page
$id = 'index.php';

// On définit quelques options :
// - le répertoire où seront stockés les fichiers de cache
// - la durée de vie du cache (ici 30 secondes)
$options = array('cacheDir' => '/tmp/','lifeTime' => 30);
// On crée un objet Cache_Lite_Output avec les options précédentes
$Cache_Lite_Output = new Cache_Lite_Output($options);
// Si la page n'est pas en cache...
echo "bonjour";
if (!($Cache_Lite_Output->start($id)))
{
  // ... alors on lance le script original

// marque la fin du script original
  $Cache_Lite_Output->end();
}

cordially.

PEAR is a dependency of Cache_Lite . How did you go about installing Cache_Lite ? Did you just unpack it into your directory, or did you actually install it using the PEAR installer (ie pear install Cache_Lite from the command line). This is the correct approach for installing PEAR packages.

It looks like you may be setting your include path incorrectly. Try it with the following:

set_include_path(get_include_path() . PATH_SEPARATOR . "/usr/share/pear");

Note the include path separator is include, as well as / before usr .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM