gpt4 book ai didi

php - Filesystem.php 第 111 行中的 ErrorException :file_put_contents(): failed to open stream: No such file or directory

转载 作者:行者123 更新时间:2023-12-02 03:55:24 26 4
gpt4 key购买 nike

我正在创建一个 API,在发出请求时我得到了这个。错误

Filesystem.php 第 111 行中的 ErrorException:
file_put_contents(/opt/lampp/htdocs/Baller/storage/framework/cache/data/ce/3c/ce3cca4e3f5b66351ec8b603994311ed663c5c5f):无法打开流:没有这样的文件或目录

我查看了我的代码,但没有发现任何内容,我也按照相关问题中的建议清除了缓存,但到目前为止没有任何效果对我有用,你们可以帮助我追踪这个错误吗?

ScheduleController.php

public function addSchedule(Request $request) {
$validator = Validator::make(
array(
'homeCourtId' => $request->homeCourtId,
'timeFrom' => $request->timeFrom,
'duration' => $request->duration,
),
array(
'homeCourtId' => 'required',
'timeFrom' => 'required',
'duration' => 'required',
)
);
if ($validator->fails()) {
$errors = $validator->errors();
if ($errors->first('homeCourtId')) {
$message = $errors->first('homeCourtId');
} else if ($errors->first('timeFrom')) {
$message = $errors->first('timeFrom');
} else if ($errors->first('duration')) {
$message = $errors->first('duration');
} else {
$message = Constant::MSG_422;
}
$this->setMeta("422", $message);
return response()->json($this->setResponse());
}
$timeFrom= $request->timeFrom;
$getDuration = $request->duration;
$duration= 360*$getDuration;
$timeTo = $timeFrom+$duration;
$userHomeCourtId= UserHomeCourt::where(array('userId'=> $request->userId,'homeCourtId'=> $request->homeCourtId, 'userHomeCourtStatus'=>Constant::STATUS_1))->pluck('userHomeCourtId');
if(!$userHomeCourtId) {
$this->setMeta('403', __('apiMessages.invalidHomeCourtId'));
return response()->json($this->setResponse());
}
try {
$schedule = new Schedule();
$schedule->userHomeCourtId = $userHomeCourtId;
$schedule->timeFrom = $request->timeFrom;
$schedule->timeTo = $timeTo;
$schedule->duration = $duration;
$schedule->save();
$this->setMeta('200', 'Schedule has been successfully set');
return response()->json($this->setResponse());
} catch (QueryException $e) {
$this->setMeta('500', Constant::MSG_500);
return response()->json($this->setResponse());
}
}

// get schedule
public function fetchSchedule(Request $request)
{
$validator = Validator::make(
array(
'homeCourtId' => $request->homeCourtId,
'currentTime' => $request->currentTime,
),
array(
'homeCourtId' => 'required',
'currentTime' => 'required',
)
);
if ($validator->fails()) {
$errors = $validator->errors();
if ($errors->first('homeCourtId')) {
$message = $errors->first('homeCourtId');
} else if ($errors->first('currentTime')) {
$message = $errors->first('currentTime');
} else {
$message = Constant::MSG_422;
}
$this->setMeta("422", $message);
return response()->json($this->setResponse());
}
$userHomeCourtId= UserHomeCourt::where(array('userId'=> $request->userId,'homeCourtId'=> $request->homeCourtId, 'userHomeCourtStatus'=>Constant::STATUS_1))->pluck('userHomeCourtId');
if(!$userHomeCourtId) {
$this->setMeta('403', __('apiMessages.invalidHomeCourtId'));
return response()->json($this->setResponse());
}
$fetchSchedule=Schedule::where('userHomeCourtId','=',$userHomeCourtId)->get();
if(!$fetchSchedule) {
$this->setMeta('200', __('apiMessages.noSchedule'));
return response()->json($this->setResponse());
}
$this->setMeta('200', __('apiMessages.scheduleList'));
$this->setData('scheduleUsers', $fetchSchedule);
return response()->json($this->setResponse());

}

路线

api.php

Route::post('/addSchedule','Api\ScheduleController@addSchedule');
Route::post('/fetchSchedule','Api\ScheduleController@fetchSchedule');

最佳答案

这只是一个权限问题,我需要使用 sudo 命令授予缓存目录的权限

$ sudo chmod 777 -R .

就是这样

关于php - Filesystem.php 第 111 行中的 ErrorException :file_put_contents(): failed to open stream: No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44126999/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com