use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); $folderPath = '/path/to/folder'; if (!$filesystem->exists($folderPath)) { $filesystem->mkdir($folderPath); }
use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); $folderPath = '/path/to/folder'; $filesystem->findOrMake($folderPath);This example is a more concise way of achieving the same result as the first example. We still create an instance of the `Filesystem` class, and define the path to the folder we want to find or make. However, we use the `findOrMake()` method to both check if the folder exists and make it if it does not. In both examples, we are using the `symfony/filesystem` package library to work with files and folders. This library provides a variety of other useful functions for working with the filesystem, such as `copy()`, `remove()`, and `chmod()`.