use Illuminate\Filesystem\Filesystem; $filesystem = new Filesystem(); // Check if a given path is a directory. if ($filesystem->isDirectory('/path/to/directory')) { // The path is a directory, do something. } // Check if multiple paths are directories. $paths = ['/path/to/directory', '/another/path']; $directories = array_filter($paths, function ($path) use ($filesystem) { return $filesystem->isDirectory($path); }); // $directories now contains only the directory paths.The Illuminate Filesystem package is part of the Laravel framework, but can also be used as a standalone package outside of Laravel.