Post here more info.
why my api routes dont work but web routes do
When i create a route on api.php and execute it from anywhere i get this response
´´´ Illuminate\Contracts\Filesystem\FileNotFoundException: File does not exist at path C:\xampp\htdocs\ProjsiteWebApp\app\storage\framework/cache/data/bc/11/bc11d69cd41accb36b5cccc6ec42558ab95cbfe0´´´
I dont have this issue with normal web.php routes.
Why is this
Not sure about the entire context of your set up however:
- Ensure your cache/storage folders are writeable.
Ex. chmod -R 777 /var/www/html/storage - Ensure you are navigating to the correct api path .
Ex: www.bookface.com/api/pictures
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.
Reference: https://laravel.com/docs/7.x/installation
- Ensure you are outputting the correct headers .
Ex: return response()->json($results, 200);
Example routes could be as followed (with or without auth):
Route::get('/photos', [PhotoController::class, 'index']); // Laravel 8 style
Route::middleware('auth:api')->resource('/photos/, 'Api\PhotosController');
Route::middleware('auth:api')->get('/photo/groups', 'Api\PhotoController@photo');
Route::middleware('auth:api')->get('/photo/workflows', 'Api\PhotoController@workflow');
Route::middleware('auth:api')->post('/photo/approve', 'Api\PhotoController@approve');
According to the documentation https://laravel.com/docs/8.x/routing :
Routes defined in the routes/api.php file are nested within a route group by the RouteServiceProvider. Within this group, the /api URI prefix is automatically applied so you do not need to manually apply it to every route in the file. You may modify the prefix and other route group options by modifying your RouteServiceProvider class.
I don't want to assume but I think it could be a folder that is not writeable?
Are you using a fresh install of Laravel? What version? Is it Lumen or full Laravel?
Try creating the file manually to see if you have permissions to write it at the full path.
# Windows example
notepad C:\xampp\htdocs\ProjsiteWebApp\app\storage\framework/cache/data/bc/11/bc11d69cd41accb36b5cccc6ec42558ab95cbfe0
# Linux example
touch /var/ProjsiteWebApp/app/storage/framework/cache/data/bc/11/bc11d69cd41accb36b5cccc6ec42558ab95cbfe0
I also noticed that the windows path included both forward and backward slashes. I am not sure if this is how the Exceptions are written to screen in Windows. But if it is simply try to write the file using backslashes
Iam using laravel 5.6
And i cant write the file with backslashes because iam not writing the file at all. The laravel framework is. Why? i dont know. All iam trying to do is create a api route
I have another laravel webservice app where i only use the api-php and not web.php. And when i check that app in the mapp location where i get filenotfound. And there is a file with the exact name of the file that is not found. I tried copy paste the file into the folder but i get the same error and also the file is deleted
How do i make it writable the storage folder??
Please or to participate in this conversation.