How to fix Composer error: “could not scan for cla

2019-02-11 17:26发布

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

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

How can I overcome this issue?

6条回答
倾城 Initia
2楼-- · 2019-02-11 18:04

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

查看更多
疯言疯语
3楼-- · 2019-02-11 18:07

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!

查看更多
冷血范
4楼-- · 2019-02-11 18:13

When you install Laravel it creates a

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.

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.

查看更多
老娘就宠你
5楼-- · 2019-02-11 18:14

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.

  1. Create a directory C:\bin
  2. Append ;C:\bin to your PATH environment variable (related help)
  3. Download https://phar.phpunit.de/phpunit-5.7.phar and save the file as C:\bin\phpunit.phar
  4. Open a command line (e.g., press Windows+R » type cmd » ENTER)
  5. Create a wrapping batch script (results in C:\bin\phpunit.cmd):

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

    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.

查看更多
Emotional °昔
6楼-- · 2019-02-11 18:16

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

查看更多
欢心
7楼-- · 2019-02-11 18:20

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

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

查看更多
登录 后发表回答