PHP code example of practically / preloader
1. Go to this page and download the library: Download practically/preloader library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
practically / preloader example snippets
#!/usr/bin/env php
use Composer\Autoload\ClassLoader;
use Practically\Preloading\Preloader;
if (!function_exists('opcache_compile_file') || !ini_get('opcache.enable')) {
echo 'Opcache is not available.';
die(1);
}
if ('cli' === PHP_SAPI && !ini_get('opcache.enable_cli')) {
echo 'Opcache is not enabled for CLI applications.';
die(1);
}
/** @var ClassLoader */
$autoloader = preload this will get of the preloader and
* preload all of the yii2 classes excluding the above and all of the app
* classes
*/
$preloader->preload('/^yii/');
$preloader->preload('/^app/');
/**
* Preload a directory of php files recucivly
*/
$preloader->preloadDirectory(__DIR__ . '/views');
ini
;
; Ensure opcache is enable
;
opcache.enable=1
;
; You may need to ensure opcache is enable for cli scripts if needed
;
opcache.enable_cli=1
;
; Set the path to the preload script and setup the user if needed
;
opcache.preload=/path/to/preload.php
opcache.preload_user=user