Support the ongoing development of Laravel.io →
posted 3 years ago
Laravel
Last updated 2 years ago.
0

Any one????

0
moderator

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);
}
Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

doxy joaodoxy Joined 11 Mar 2021

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.