无法打开流:没有这样的文件或目录(Laravel)

Posted

技术标签:

【中文标题】无法打开流:没有这样的文件或目录(Laravel)【英文标题】:failed to open stream: No such file or directory (Laravel) 【发布时间】:2018-11-08 07:41:26 【问题描述】:

出于测试目的,我将 UsersController.php 文件重命名为 ~UsersController.php,一切正常,直到我将其重命名为 UsersController.php,现在我收到以下错误

include(C:\xampp\htdocs\xxx\vendor\composer/../../app/Http/Controllers/~UsersController.php): failed to open stream: No such file or directory

当我想将表单提交到UsersController 时,我收到了上述错误,而我没有更改路由文件或视图中的任何内容。

【问题讨论】:

试试php artisan config:cachephp artisan config:clearcomposer dump-autoload -o 我可以添加为答案吗? @VaheShak 当然,您可以将其发布为答案。我会投票+1 【参考方案1】:

试试 php artisan config:cache php artisan config:clear composer dump-autoload -o

【讨论】:

我重命名控制器后发生的错误。这个答案解决了它。 php artisan config:clear 不需要 config:cache 会在此之前完成:配置缓存已清除!配置缓存成功!配置缓存清除!配置缓存成功! @vahe-shak php artisan config:cachephp artisan config:clearcomposer dump-autoload -o 有什么区别? 您能否更新一下 asnwer 以解释每个命令的作用。 Laravel 指定 You should typically run the php artisan config:cache command as part of your production deployment process. The command should not be run during local development as configuration options will frequently need to be changed during the course of your application's development. 如果没有解释,人们可能会盲目地运行您的代码,从而产生后果。 如果你正在开发,我建议先运行config:clear,然后尝试看看它是否有效【参考方案2】:

在我的情况下,问题在于自动加载器加载旧的已删除文件,所以我只使用了“composer dump-autoload -o”并且它起作用了

【讨论】:

【参考方案3】:

在我的情况下,问题出在它读取旧路径的内部存储库中, 解决方案是使用composer update 读取新的存储库路径。

【讨论】:

【参考方案4】:

使用此代码。 ? 您必须在项目文件夹中运行 composer dumpautoload

【讨论】:

请对您的回答进行详细解释,以便下一位用户更好地理解您的回答。【参考方案5】:

在我的情况下,使用命令“composer update”很有用,你也可以使用命令composer dump

【讨论】:

以上是关于无法打开流:没有这样的文件或目录(Laravel)的主要内容,如果未能解决你的问题,请参考以下文章

Laravel Telescope 无法打开流:没有这样的文件或目录 TelescopeServiceProvider.php

将 laravel 部署到 Nginx 中出现错误“无法打开流:没有这样的文件或目录”

file_put_contents,无法打开流:没有这样的文件或目录 Laravel [重复]

Laravel 5 显示 ErrorException file_put_contents 无法打开流:没有这样的文件或目录

警告:无法打开流:第 17 行的 C:\wamp\www\laravel\bootstrap\autoload.php 中没有这样的文件或目录

如何修复 laravel 作曲家更新问题( Illuminate\Foundation\ComposerScripts::postAutoloadDump 无法打开流:没有这样的文件或目录)