How to delete directory in laravel6 with example

Today, in this article we will share with you with an example of how to delete a directory in laravel and as well as in PHP. we all know this is very small things but very helpful in any laravel application or PHP project. you many times need in your laravel project deleted any particular directory when some specific task is done and that directory no need to longer.

You can do this task in laravel help of deleteDirectory() function. we all know laravel's File class provides many helpfull functions which can help lots of related files and directory tasks.

Example for laravel

In laravel first, we need to create one dummy directory in public folder like public/dummy_directory. and in this example, we will show how to delete it.

public function index()
{
    $folderPath = public_path('dummy_directory');

    $dd = File::deleteDirectory($folderPath);

    dd($dd);
}

 

Tags: