PHP
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

apc_define_constants> <apc_clear_cache
Last updated: Fri, 26 Dec 2008

view this page in

apc_compile_file

(PECL apc >= 3.0.13)

apc_compile_fileStocke un fichier dans le cache, en évitant tous les filtres

Description

bool apc_compile_file ( string $filename )

Stocke un fichier dans le cache, en évitant tous les filtres.

Liste de paramètres

filename

Chemin complet ou relatif vers un fichier PHP qui sera compilé et stocké dans le cache.

Valeurs de retour

Cette fonction retourne TRUE en cas de succès, FALSE en cas d'échec.



add a note add a note User Contributed Notes
apc_compile_file
Andrea Giammarchi
15-Feb-2008 04:40
This is a simple way to cache a project entirely.

<?php // apc_compile_dir.php
function apc_compile_dir($root, $recursively = true){
   
$compiled   = true;
    switch(
$recursively){
        case   
true:
            foreach(
glob($root.DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR) as $dir)
               
$compiled   = $compiled && apc_compile_dir($dir, $recursively);
        case   
false:
            foreach(
glob($root.DIRECTORY_SEPARATOR.'*.php') as $file)
               
$compiled   = $compiled && apc_compile_file($file);
            break;
    }
    return 
$compiled;
}
?>

This is an example on how to use the function to compile your project.
<?php
echo    '<pre>'.PHP_EOL;
if(
function_exists('apc_compile_file')){
   
define('APC_CLEAR_CACHE',           true);
   
define('APC_COMPILE_RECURSIVELY',   true);
   
define('APC_COMPILE_DIR',           '.');
    require
'apc_compile_dir.php';
    echo   
'APC Directory Compiler '.gmdate('Y-m-d H:i:s').PHP_EOL;
    echo   
PHP_EOL.'-------------------------'.PHP_EOL;
    if(
APC_CLEAR_CACHE){
        echo    (
apc_clear_cache() ? 'Cache Cleaned' : 'Cache Not Cleaned').PHP_EOL;
       
var_dump(apc_cache_info());
        echo   
PHP_EOL.'-------------------------'.PHP_EOL;
    }
    echo   
'Runtime Errors'.PHP_EOL;
    echo    (
apc_compile_dir(APC_COMPILE_DIR, APC_COMPILE_RECURSIVELY) ? 'Cache Created' : 'Cache Not Created').PHP_EOL;
    echo   
PHP_EOL.'-------------------------'.PHP_EOL;
   
var_dump(apc_cache_info());
}
else
    echo   
'APC is not present, nothing to do.'.PHP_EOL;
echo   
'</pre>';
?>

apc_define_constants> <apc_clear_cache
Last updated: Fri, 26 Dec 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites