How to fix Composer error: “could not scan for classes inside dir”?

社会主义新天地 提交于 2019-12-17 19:08:10

问题


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?


回答1:


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




回答2:


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.




回答3:


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:


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




回答5:


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.




回答6:


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




回答7:


I think it happens because composer cache error. Try to clear its cache:

composer clearcache

then run the installer again

composer create-project --prefer-dist laravel/laravel blog


来源:https://stackoverflow.com/questions/20595801/how-to-fix-composer-error-could-not-scan-for-classes-inside-dir

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!