如何修正作曲家错误:“不能扫描目录内的类”?

时间:2021-01-10 17:05:14

I'm trying to install composer in terminal by entering this command:

我正试图通过输入以下命令来在终端安装composer:

php composer.phar install

it starts to install required packages but I'm getting this error type:

它开始安装所需的软件包,但我得到了这个错误类型:

[RuntimeException]
Could not scan for classes inside "app/commands" which does not appear to be a file nor a folder

[RuntimeException]不能扫描“应用程序/命令”内的类,这些类不是文件,也不是文件夹。

How can I overcome this issue?

我如何克服这个问题?

6 个解决方案

#1


13  

When you install Laravel it creates a

当你安装Laravel时,它会创建一个。

app/commands

folder. Looks like it's not there. Just create it or remove from composer.json:

文件夹中。看起来好像不在那里。只需要创建或删除它。

"classmap": [
    "app/commands",  /// <--- this line
],

And run

和运行

composer update
artisan dump-autoload

The last one is similar to composer dump-autoload, but it does some Laravel stuff too.

最后一个类似于作曲家dump-autoload,但它也做了一些Laravel的东西。

If you don't have any commands you don't really need it. If you plan to create artisan commands, create that folder and it should work.

如果你没有任何命令,你就不需要它。如果您计划创建artisan命令,请创建该文件夹,它应该可以工作。

#2


5  

Usually this happens when you have some corrupted files or any composer update has crashed or interrupted.

通常情况下,当您有一些损坏的文件或任何编写器更新崩溃或中断时,就会发生这种情况。

To solve, just delete the vendor folders and run composer install

要解决这个问题,只需删除供应商文件夹并运行composer安装。

#3


4  

I had the same problem. In my case, I noticed that there was no app/commands folder in my laravel install. I created the commands folder and composer dump-autoload was working again!

我遇到了同样的问题。在我的例子中,我注意到在我的laravel安装中没有应用程序/命令文件夹。我创建了命令文件夹,而作曲家dump-autoload又开始工作了!

#4


2  

My problem was that I've had App instead of app in my directory path. Maybe this will help someone.

我的问题是,我在我的目录路径中使用了App而不是应用程序。也许这对某人有帮助。

#5


0  

I am Xampp user on Windows 10. I try all of the above methods but none of them work for me. I fixed my problem with this method, and Hopefully, it will help others.

我是Windows 10的Xampp用户。我尝试了以上所有方法,但没有一个方法适合我。我用这个方法解决了我的问题,希望它能帮助别人。

  1. Create a directory C:\bin
  2. 创建一个目录C:\ bin
  3. Append ;C:\bin to your PATH environment variable (related help)
  4. C:\bin到您的PATH环境变量(相关帮助)
  5. Download https://phar.phpunit.de/phpunit-5.7.phar and save the file as C:\bin\phpunit.phar
  6. 下载https://phar.phpunit.de/phpunit-5.7.phar并将文件保存为C:\bin\phpunit.phar。
  7. Open a command line (e.g., press Windows+R » type cmd » ENTER)
  8. 打开命令行(例如,按Windows+R»类型cmd»输入)
  9. Create a wrapping batch script (results in C:\bin\phpunit.cmd):

    创建一个包装批处理脚本(结果为C:\bin\phpunit.cmd):

    C:\Users\username> cd C:\bin
    C:\bin> echo @php "%~dp0phpunit.phar" %* > phpunit.cmd
    C:\bin> exit
    
  10. Open a new command line and confirm that you can execute PHPUnit from any path:

    打开一个新的命令行,并确认可以从任何路径执行PHPUnit:

    C:\Users\username> phpunit --version
    PHPUnit x.y.z by Sebastian Bergmann and contributors.
    

This method solves my problem. Hope It will save your day too.

这个方法解决了我的问题。希望它也能拯救你的一天。

#6


0  

I had the same issue. For me it happened after I deleted a class dir and forgot to update composer.json.

我有同样的问题。对我来说,它发生在我删除了一个类目录并忘记了更新。json。

The fix was simply updating the classmap array in composer.json

修复程序只是简单地将classmap数组更新为composer.json。

#1


13  

When you install Laravel it creates a

当你安装Laravel时,它会创建一个。

app/commands

folder. Looks like it's not there. Just create it or remove from composer.json:

文件夹中。看起来好像不在那里。只需要创建或删除它。

"classmap": [
    "app/commands",  /// <--- this line
],

And run

和运行

composer update
artisan dump-autoload

The last one is similar to composer dump-autoload, but it does some Laravel stuff too.

最后一个类似于作曲家dump-autoload,但它也做了一些Laravel的东西。

If you don't have any commands you don't really need it. If you plan to create artisan commands, create that folder and it should work.

如果你没有任何命令,你就不需要它。如果您计划创建artisan命令,请创建该文件夹,它应该可以工作。

#2


5  

Usually this happens when you have some corrupted files or any composer update has crashed or interrupted.

通常情况下,当您有一些损坏的文件或任何编写器更新崩溃或中断时,就会发生这种情况。

To solve, just delete the vendor folders and run composer install

要解决这个问题,只需删除供应商文件夹并运行composer安装。

#3


4  

I had the same problem. In my case, I noticed that there was no app/commands folder in my laravel install. I created the commands folder and composer dump-autoload was working again!

我遇到了同样的问题。在我的例子中,我注意到在我的laravel安装中没有应用程序/命令文件夹。我创建了命令文件夹,而作曲家dump-autoload又开始工作了!

#4


2  

My problem was that I've had App instead of app in my directory path. Maybe this will help someone.

我的问题是,我在我的目录路径中使用了App而不是应用程序。也许这对某人有帮助。

#5


0  

I am Xampp user on Windows 10. I try all of the above methods but none of them work for me. I fixed my problem with this method, and Hopefully, it will help others.

我是Windows 10的Xampp用户。我尝试了以上所有方法,但没有一个方法适合我。我用这个方法解决了我的问题,希望它能帮助别人。

  1. Create a directory C:\bin
  2. 创建一个目录C:\ bin
  3. Append ;C:\bin to your PATH environment variable (related help)
  4. C:\bin到您的PATH环境变量(相关帮助)
  5. Download https://phar.phpunit.de/phpunit-5.7.phar and save the file as C:\bin\phpunit.phar
  6. 下载https://phar.phpunit.de/phpunit-5.7.phar并将文件保存为C:\bin\phpunit.phar。
  7. Open a command line (e.g., press Windows+R » type cmd » ENTER)
  8. 打开命令行(例如,按Windows+R»类型cmd»输入)
  9. Create a wrapping batch script (results in C:\bin\phpunit.cmd):

    创建一个包装批处理脚本(结果为C:\bin\phpunit.cmd):

    C:\Users\username> cd C:\bin
    C:\bin> echo @php "%~dp0phpunit.phar" %* > phpunit.cmd
    C:\bin> exit
    
  10. Open a new command line and confirm that you can execute PHPUnit from any path:

    打开一个新的命令行,并确认可以从任何路径执行PHPUnit:

    C:\Users\username> phpunit --version
    PHPUnit x.y.z by Sebastian Bergmann and contributors.
    

This method solves my problem. Hope It will save your day too.

这个方法解决了我的问题。希望它也能拯救你的一天。

#6


0  

I had the same issue. For me it happened after I deleted a class dir and forgot to update composer.json.

我有同样的问题。对我来说,它发生在我删除了一个类目录并忘记了更新。json。

The fix was simply updating the classmap array in composer.json

修复程序只是简单地将classmap数组更新为composer.json。