Monday, March 6, 2017

'Failed to open stream: Permission denied' error - Laravel 5.4

I run my webserver on windows (XAMPP Control Panel v3.2.2). I am creating files and folders like this:

...
$Path = app_path()
       . '/Projects/'
       . strtolower($Project->name)
       . '/Schema/';

if (File::exists($Path)) {
    $result = 1;
} else {
    $result = File::makeDirectory($unitPath , '775', true);

    $content = "the content is basically a whole controller";

    $file   = $Path . strtolower($Unit->name) . '.php';
    $bytes_written = File::put($file, $content);

    if ($bytes_written === false) {
        return false;
    }
}

The file which I create is a PHP controller.

The files and folders are created. However by using git bash I noticed that the permission is not set to 775 even though I have specified it in makeDirectory, same for the files.

git bash enter image description here

If I try to execute an action from the created file (which is a controller), then I get:

ErrorException in C:\xampp\htdocs\selenium\vendor\composer\ClassLoader.php line 440: include(C:\xampp\htdocs\selenium): failed to open stream: Permission denied

How can I solve this, other than running my webserver on linux instead of windows?

NOTE: Everything works fine on my computer at home, where I also run the webserver on windows.



via EdwardBlack

Advertisement