Reputation: 11
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.
Upvotes: 0
Views: 2505
Reputation: 8003
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 (i.e. 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
.
Upvotes: 2