argument('path'); if ( ! is_dir($directoryPath)) { $this->error('The path is invalid: not a directory.'); return; } $redis = Redis::connection(); $redis->set('analyze_performance_time', Carbon::now()->format('U')); $redis->set('analyze_performance_path', $directoryPath); $allFiles = $this->getDirContents($directoryPath); $redis->set('analyze_performance_remaining_files', count($allFiles)); foreach ($allFiles as $index => $file) { $handler = new DocumentHandler( $index, 'md', new UploadedFile($file, "File {$index}"), false ); $handler->handle(); } $this->info('Processing... When it\'s done the results will be added to the \'ingest_analyze_performance.txt\' file in the directory you have provided.'); } protected function getDirContents($dir, &$results = array()) { $files = scandir($dir); foreach ($files as $key => $value) { $path = realpath($dir . DIRECTORY_SEPARATOR . $value); if (!is_dir($path)) { $results[] = $path; } else if ($value != "." && $value != "..") { $this->getDirContents($path, $results); } } return $results; } }