use Symfony\Component\Filesystem\Filesystem; $fs = new Filesystem(); $fs->dumpFile('/path/to/file.txt', 'Hello World!');
use Symfony\Component\Filesystem\Filesystem; $fs = new Filesystem(); $data = ['name' => 'John Smith', 'age' => 35]; $jsonData = json_encode($data); $fs->dumpFile('/path/to/file.json', $jsonData);In this example, an array containing some data is first encoded to JSON using the json_encode function. The resulting string is then written to a file using the dumpFile method. The package library for the Symfony\Component\Filesystem library is Symfony/Filesystem.