Gaufrette提供了一个文件系统的抽象层的PHP5库。它使得以相同方式操控本地文件,FTP服务器,亚马逊S3等等。它允许你开发程序时,不用了解未来你将怎么访问你的文件。
示例代码:
<?phpuse 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. '%kerel.root_dir%/cache/%kerel.eviromet%/filesystem') with create = true$local = ew LocalAdapter($cacheDirectory, true);// FTP Adapter with a defied root-path$ftp = ew FtpAdapter($path, $host, $userame, $password, $port);// Cached Adapter with 3600 secods time to live$cachedFtp = ew CacheAdapter($ftp, $local, 3600);$filesystem = ew Filesystem($cachedFtp);









评论