namespace Illuminate\Filesystem;
use ErrorException;
use FilesystemIterator;
use Symfony\Component\Finder\Finder;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
// long time ago ,never see namespace so better, now I will use it more
class Filesystem
{
use Macroable;// this is a trait class like a real class
/**
* Determine if a file or directory exists.
*
* @param string $path
* @return bool
*/
public function exists($path)
{
return file_exists($path);// a method wrap
}// Determine if a file or directory exists.
/**
* Get the contents of a file.
*
* @param string $path
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function get($path)
{
if ($this->isFile($path)) {// Determine is a file
return file_get_contents($path);//get file contents
}
throw new FileNotFoundException("File does not exist at path {$path}");
}// get file contents
[李景山php]每天laravel-20160910|Filesystem-1
最新推荐文章于 2023-12-28 10:38:37 发布