在路径中找不到Laravel文件,但它确实存在 [英] Laravel File not found at path but it does exist

查看:1140
本文介绍了在路径中找不到Laravel文件,但它确实存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试获取文件内容时在控制台中出现以下错误:

Getting the following error in console when attempting to get a files contents:

[League \ Flysystem \ FileNotFoundException]在路径中找不到文件: C:/wamp64/www/lion/resources/generate/json/Car.json

[League\Flysystem\FileNotFoundException] File not found at path: C:/wamp64/www/lion/resources/generate/json/Car.json

当我将该确切路径复制并粘贴到资源管理器中时,它会很好地打开json文件.

When I copy and paste that exact path in explorer it opens the json file fine.

这是我的代码:

$this->json = json_encode(Storage::get(resource_path('generate/json/'.$this->argument('model').'.json')));

推荐答案

我知道了.

Storage::get实际上使用相对于文件系统磁盘配置的路径,因此错误消息本身具有误导性.

Storage::get actually uses the path relative to the filesystem disk configuration, therefore the error message itself is misleading.

我已经通过简单地使用file_get_contents()纠正了这个问题.

I've corrected the issue by simply using file_get_contents() instead.

这篇关于在路径中找不到Laravel文件,但它确实存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆