src/OpcacheClass.php
public function optimize()
    {
        if (! function_exists('opcache_compile_file')) {
            return false;
        }

        // Get files in these paths
        $files = File::allFiles(config('opcache.directories'));

        $files = collect($files);

        // filter on php extension
        $files = $files->filter(function ($value) {
            return File::extension($value) == 'php';
        });

        // optimized files
        $optimized = 0;

        $files->each(function ($file) use (&$optimized) {
            if (! opcache_is_script_cached($file)) {
                if (@opcache_compile_file($file)) {
                    $optimized++;
                }
            }
        });

        return [
            'total_files_count' => $files->count(),
            'compiled_count'    => $optimized,
        ];
    }
public function optimize()
    {
        if (! function_exists('opcache_compile_file')) {
            return false;
        }

        // Get files in these paths
        $files = File::allFiles(config('opcache.directories'));

        $files = collect($files);

        // filter on php extension
        $files = $files->filter(function ($value) {
            return File::extension($value) == 'php';
        });

        // optimized files
        $optimized = 0;

        $files->each(function ($file) use (&$optimized) {
            if (! opcache_is_script_cached($file)) {
                if (@opcache_compile_file($file)) {
                    $optimized++;
                }
            }
        });

        return [
            'total_files_count' => $files->count(),
            'compiled_count'    => $optimized,
        ];
    }
public function optimize ( ) { if ( ! function_exists ( 'opcache_compile_file' ) ) { return false ; } // Get files in these paths $ files = File :: allFiles ( config ( 'opcache.directories' ) ) ; $ files = collect ( $ files ) ; // filter on php extension $ files = $ files -> filter ( function ( $ value ) { return File :: extension ( $ value ) == 'php' ; } ) ; // optimized files $ optimized = 0 ; $ files -> each ( function ( $ file ) use ( & $ optimized ) { if ( ! opcache_is_script_cached ( $ file ) ) { if ( @ opcache_compile_file ( $ file ) ) { $ optimized ++ ; } } } ) ; return [ 'total_files_count' => $ files -> count ( ) , 'compiled_count' => $ optimized , ] ; }
Precompile app.

@return bool | array
Precompile app .