GaufrettePHP文件系統(tǒng)抽象層
Gaufrette 提供了一個文件系統(tǒng)的抽象層的PHP5庫。它使得以相同方式操控本地文件,F(xiàn)TP服務器,亞馬遜 S3等等。它允許你開發(fā)程序時,不用了解未來你將怎么訪問你的文件。
示例代碼:
<?php use Gaufrette\Filesystem; use Gaufrette\Adapter\Ftp as FtpAdapter; use Gaufrette\Adapter\Local as LocalAdapter; use Gaufrette\Adapter\Cache as CacheAdapter; // Locale Cache-Directory (e.g. '%kernel.root_dir%/cache/%kernel.environment%/filesystem') with create = true $local = new LocalAdapter($cacheDirectory, true); // FTP Adapter with a defined root-path $ftp = new FtpAdapter($path, $host, $username, $password, $port); // Cached Adapter with 3600 seconds time to live $cachedFtp = new CacheAdapter($ftp, $local, 3600); $filesystem = new Filesystem($cachedFtp);
評論
圖片
表情
