You tried to give a parameter to flock that is a boolean and not a resource. Without knowing more it is very difficult to help.
But lets assume you use fopen to open a file, then this can maybe help you.
public function errorLog()
{
$resource = fopen('/path/to/file', 'r+');
if (!$resource) {
throw new \Exception('failed to open a file handler');
}
$lock = flock($resource, LOCK_EX);
if (!$lock) {
throw new \Exception('failed to get lock');
}
// do something and release the lock
flock($resource, LOCK_UN);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community