Laravel classloader.php 错误无法打开流:没有这样的文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31284774/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:20:55  来源:igfitidea点击:

Laravel classloader.php error failed to open stream: No such file or directory

phpmysqllaravellaravel-5

提问by Matt

I am able to run "php artisan migrate" fine. I'm able to get all the form input if I use Request::all() but when I try to add the data to my mysql database table I get the below error:

我能够很好地运行“php artisan migrate”。如果我使用 Request::all() ,我可以获得所有表单输入,但是当我尝试将数据添加到我的 mysql 数据库表时,我收到以下错误:

ErrorException in ClassLoader.php line 412:
include(Correct_Path/full-personal/database/migrations/2015_07_06_035501_resume_requesters.php): failed to open stream: No such file or directory

I currently have the form attached to a controller method with the below code:

我目前将表单附加到具有以下代码的控制器方法:

 $input = Request::all();
    ResumeRequesters::create($input);

I know that I am properly connected to mysql server because I'm able to migrate my migrations.

我知道我已正确连接到 mysql 服务器,因为我能够迁移我的迁移。

Any help would be great. Also why did laravel change so many things in Laravel 5?

任何帮助都会很棒。还有为什么 Laravel 在 Laravel 5 中改变了这么多东西?

Thanks

谢谢

回答by Jigs Virani

You have to run composer dumpautoloadinside your project folder.

您必须composer dumpautoload在项目文件夹中运行。

回答by codeboye

This has happened to me in my Windows 10 machine using a 2 years-old Laravel project from bitbucket. If the composer dump-autoloadwon't work for you, then the error tells you that a directory is missing in my case, there was no migrationsfolder inside the databasedirectory.

这发生在我的 Windows 10 机器上,使用了来自 bitbucket 的 2 年前的 Laravel 项目。如果这composer dump-autoload对您不起作用,那么错误会告诉您在我的情况下缺少目录,数据库目录中没有迁移文件夹。

Solution:Create the migrationsfolder inside the databasedirectory. You can do this using your IDE, or Windows's File Explorer. If your using Git Bash, cd to your project's databasefolder then do mkdir migrationsto create the missing migrationsdirectory.

解决方案:数据库目录中 创建迁移文件夹。您可以使用 IDE 或 Windows 的文件资源管理器执行此操作。如果您使用 Git Bash,请 cd 到您项目的数据库文件夹,然后创建丢失的迁移目录。mkdir migrations

回答by Nikunj Shah

One of the reason of this kind of error is that when you deleted something from your project like login module then auto-file-loader does contain that file information when you deleted something , so therefore if you are deleting something , then after deleting something from your project,so shoude run command composer dumpautoload then it show following logs Generating optimized autoload files

此类错误的原因之一是,当您从项目中删除某些内容(如登录模块)时,自动文件加载器确实会在您删除某些内容时包含该文件信息,因此,如果您要删除某些内容,则在从中删除某些内容之后你的项目,所以应该运行命令 composer dumpautoload 然后它显示以下日志生成优化的自动加载文件

@php artisan package:discover --ansi Discovered Package: facade/ignition Discovered Package: fideloper/proxy Discovered Package: fruitcake/laravel-cors Discovered Package: laravel/tinker Discovered Package: laravel/ui Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Package manifest generated successfully. Generated optimized autoload files containing 4334 classes you can run your project again PS D:\laravel\myApp> php artisan serve

@php artisan package:discover --ansi 发现包:facade/ignition 发现包:fideloper/proxy 发现包:fruitcake/laravel-cors 发现包:laravel/tinker 发现包:laravel/ui 发现包:nesbot/carbon 发现包: nunomaduro/collision 包清单生成成功。生成包含 4334 个类的优化自动加载文件,您可以再次运行您的项目 PS D:\laravel\myApp> php artisan serve

回答by Amitesh

ClassLoader.php Load the given class file into Laravel. Similar errors are due to failure to autoload new classes.

ClassLoader.php 将给定的类文件加载到 Laravel 中。类似的错误是由于未能自动加载新类。

composer dump-autoload

composer dump-autoload regenerates the list of all classes that need to be included in the project (autoload_classmap.php). It won't download anything.

composer dump-autoload 重新生成需要包含在项目中的所有类的列表(autoload_classmap.php)。它不会下载任何东西。

When to use:When you have a new class inside your project, Run it from the project root.

何时使用:当您的项目中有一个新类时,从项目根目录运行它。