Skip to content

Commit

Permalink
Merge pull request #76 from The-Hasanov/master
Browse files Browse the repository at this point in the history
optimize file find proccess
  • Loading branch information
ovanschie authored Jun 17, 2019
2 parents f2dd70a + e4b8b0f commit 899ed38
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/OpcacheClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Appstract\Opcache;

use Illuminate\Support\Facades\File;
use Symfony\Component\Finder\Finder;

/**
* Class OpcacheClass.
Expand Down Expand Up @@ -75,23 +75,18 @@ public function optimize()
}

// Get files in these paths
$files = File::allFiles(config('opcache.directories'));
$files = Finder::create()->in(config('opcache.directories'))
->name('*.php')
->files();

$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++;
}
if (!opcache_is_script_cached($file) && @opcache_compile_file($file)) {
$optimized++;
}
});

Expand Down

0 comments on commit 899ed38

Please sign in to comment.