$userAndGroup = str_replace(' ', ':', exec('ps -p ' . getmypid() . ' -o user,group'));
if (!is_readable($pathToFile) || !is_writable($pathToFile)) {
echo "sudo chown -R $userAndGroup $pathToFile";
}
$userData = posix_getpwuid(posix_getuid());
$userName = $userData['name'];
$groupName = posix_getgrgid($userData['gid'])['name'];
if (!is_readable($pathToFile) || !is_writable($pathToFile)) {
echo "sudo chown -R $userName:$groupName $pathToFile";
}