I know this is a common bug with many threads but I\'m tired of searching and I still haven\'t solved it. When I try to run the function file_put_contents I get
chcon -Rv --type=httpd_sys_rw_content_t /dir
This may help,rather than turn off the selinux.