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

fbmfbm's avatar

file_put_content error : failed to open stream: Permission denied

Hi all, i'm updating an laravel app from 5.5 to 5.8 by add all the update states (5.5 to 5.6.....5.8) and all is working on my windows developpement sys. But i want to clone this state to my osx alternative developpement environnement and i have some strange acces error :

file_put_contents(/fgTrTnBjujXVEJLAvRSUak4PmDhNjKdqytkNwuHb): failed to open stream: Permission denied

i know that rights on directorys and files must be set to good level, but even i set 777 access right to all directorys and files for i get this error on index.php access. It's certainly on session write but can't figure why i get this error.

I have use all the cache clear commande and dump autoload after each access right modification without result. I have the views and session directory in storage directory to...! Any one know about this ? I'm really in trouble for my app update.

Thank's for your help fbm

0 likes
6 replies
Sinnbeck's avatar

Are you are that is the exact error? That refers to the root of your hdd, not laravel. Can you post the exact error

fbmfbm's avatar

thanks for our reply :

@maverickchan i have even made cache:clear clear-compiled view:clear config:clear and dump autoload but without result.

@ Sinnbeck : this is the exact error message : file_put_contents(/fgTrTnBjujXVEJLAvRSUak4PmDhNjKdqytkNwuHb): failed to open stream: Permission denied

the file initiator is /vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php in my app and yes it's strange that the error point to the hdd root. this is the session that try to write a file but i don't use file session system but cookies.... Maybe the updating session system change something from 5.5 to 5.8..?

fbmfbm's avatar

OSX v 10.13..6.. I'm cloning the same app from git on windows and all is working fine ;(( sure...no files right system on it.

fbmfbm's avatar

For other in the same trouble, I found the solution :

Sham on me, my first mistake was i have one line in .env file with SESSION_DRIVER=file that overide my first SESSION_DRIVER=cookies in then file ....

And on update process from 5.5 to 5.6, i need to delete the trustedProxy.php in config and update http\middleware\TrusProxies.php to :

<?php

namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;


class TrustProxies extends Middleware
{
    /**
     * The trusted proxies for this application.
     *
     * @var array|string
     */
    protected $proxies;
    /**
     * The headers that should be used to detect proxies.
     *
     * @var int
     */
    protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

next, config:clear cache:clear clear-compiled and composer dump-autoload.

Please or to participate in this conversation.