Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vandyczech's avatar

Check is directory exist

Please help me, how can I simply find out if the directory exist or not? I search some simply method support with Laravel 5 minimal. Thx

No working method:

file_exists()
0 likes
9 replies
Mariam's avatar
if(!File::exists($path)) {
    // path does not exist
}
vandyczech's avatar

This is not working :( My path is:

$path = base_path() . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $request->theme_name ;

// example
storage / app / themes / basic

I need check, if the basic folder exist or not.

puzbie's avatar

@vandyczech both PHP and laravel itself has far more functionality than most people will ever need. Just because you don't know one aspect doesn't make you stupid. I am forever having to google the various string functions for instance. So many different languages do the same thing in slightly different ways that it becomes impossible to memorise everything.

1 like

Please or to participate in this conversation.