Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 8 return flock error on api request

Tags:

php

laravel

I'm very stuck with an error that i can't understand, Laravel 8 response always "flock() expects parameter 1 to be resource, bool given" In all api routes. I made a simple route to debug this issue but i'm not have a little idea what the problem is, so if someone could get me some help about this i'll be would be great. This is my code:

API Routes

Route::post('/createUser',[UserController::class, 'store'])->name('createUser');
Route::get('/getUser',[UserController::class, 'index'])->name('getUser');

Route::middleware(['auth:sanctum'])->group(function () {
    Route::prefix('V1')->group(function () {
        
        // Rutas para los VDP
        Route::get('/conf',[ReaderController::class, 'readerInitialConf'])->name('readerInitialConf');
        Route::post('/createReader',[ReaderController::class, 'store'])->name('createReader');


    });
}); 

Controller Code:

public function index()
    {
        return User::all();
    }

And this is Postman:

enter image description here

Note: This application is dockerized, I don't know if docker might cause this problem, but i think not, because i always use it and never get this problem.

If someone could help, i'll be very thankfull.

Thanks in advance! Raul

like image 818
Raul Biancardi Avatar asked Apr 23 '26 01:04

Raul Biancardi


1 Answers

Check permissions of storage/framework/cache/data just to define 777 to the storage/framework/cache won't be enough, you should also give the webserver user permissions to write into that folder, typically the user is: www-data or _www.

The right thing is to have 775 permissions to this folder then change only the grupo to allow both your user and the webserver user to write into those folders.

chmod 775 storage/framework/cache
chmod 775 storage/framework/cache/data

sudo chgrp www-data storage/framework/cache
sudo chgrp www-data storage/framework/cache/data
like image 108
Adriano Rosa Avatar answered Apr 24 '26 14:04

Adriano Rosa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!