use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); // Check if a file exists if ($filesystem->exists('/path/to/file.txt')) { echo 'File exists'; } else { echo 'File does not exist'; } // Check if a directory exists if ($filesystem->exists('/path/to/dir')) { echo 'Directory exists'; } else { echo 'Directory does not exist'; }In the above examples, the `exists` method is used to check if a file or directory exists on the filesystem. Depending on the result, it outputs a message to the console. The `Filesystem` class is part of the Symfony Filesystem component, which is a package library for PHP that provides a set of utilities to manipulate the filesystem.