note 81146 added to function.apc-compile-file

From: Date: Fri, 15 Feb 2008 15:40:13 +0000
Subject: note 81146 added to function.apc-compile-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-136178@lists.php.net to get a copy of this message
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>'; ?> ---- Server IP: 194.145.210.3 Probable Submitter: 213.123.186.247 ---- Manual Page -- http://www.php.net/manual/en/function.apc-compile-file.php Edit -- https://master.php.net/note/edit/81146 Del: integrated -- https://master.php.net/note/delete/81146/integrated Del: useless -- https://master.php.net/note/delete/81146/useless Del: bad code -- https://master.php.net/note/delete/81146/bad+code Del: spam -- https://master.php.net/note/delete/81146/spam Del: non-english -- https://master.php.net/note/delete/81146/non-english Del: in docs -- https://master.php.net/note/delete/81146/in+docs Del: other reasons-- https://master.php.net/note/delete/81146 Reject -- https://master.php.net/note/reject/81146 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136178) next »