You are getting this error as the user trying to create the folder does not have permission to create a folder in that directory.
You should ensure that the user your web application runs as has sufficient privileges to write files to your project.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I have a scheduled command that sometimes creates a new directory, however on a server it doesn't actually work unless I were to run it manually with sudo.
It would return an error that it does not have permissions to mkdir() from the statement like File::makeDirectory($myImageFolder, 0755, true)
My question is, what's the best way to handle this scenario?
It seems like the problem was being caused because the folder in which directories was being made, was made by root
Therefore, when forge tried to create a directory, it didn't have permissions to make the directory.
The solution was to use sudo chown forge:forge folderName -R and once that was done, everything began to work like a charm and File::makeDirectory($examplePath, 0755, true) worked in scheduled commands and in tinker
Thanks to everyone who helped :) @hajrovica @jryd
Please or to participate in this conversation.