function save_project($project_info, $filename){ $file = fopen($filename, 'w'); fwrite($file, $project_info); fclose($file); }
use Symfony\Component\Filesystem\Filesystem; class ProjectManager { private $filesystem; public function __construct(){ $this->filesystem = new Filesystem(); } public function save_project($project_info, $filename){ $this->filesystem->dumpFile($filename, $project_info); } public function get_project($filename){ return $this->filesystem->exists($filename) ? file_get_contents($filename) : null; } }In this example, we used the Filesystem package provided by the Symfony framework. The package provides a set of classes and functions for working with the file system. We used the dumpFile method to write the project information to a file and exists method to check if the file exists before retrieving it.