Determining If a File Exists


You want to see if a file exists.

You know you can use the PHP file_exists() method, but want to do it the Laravel way.


Use the File::exists() method.

if (File::exists($myfile))
    echo "Yup. It exists.";


This method actually calls file_exists().

But it does allow better testing because using the facade allows you to easily mock the method when needed.

comments powered by Disqus