Laravel 4.2 Composer 安装错误:"could not scan for classes"

6

我想在我的新Laravel 4.2安装中通过Composer安装一些包。然而,我遇到了一个异常。

这是我的Composer文件:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "license": "MIT",   
    "require": {
        "laravel/framework": "4.2.*",
        "zizaco/confide": "~4.0@dev",
        "zizaco/entrust": "1.2.*@dev",
        "barryvdh/laravel-ide-helper": "1.*",
        "fzaninotto/faker": "1.3.*@dev",
        "bllim/datatables": "~1.3",
        "barryvdh/laravel-debugbar": "~1.7"
    },
    "require-dev": {
        "way/generators": "~2.6",
        "barryvdh/laravel-ide-helper": "~1.11"
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php",
            "app/controllers/admin",
            "app/controllers/user"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd":[
            "php artisan ide-helper:generate"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable"
}

运行composer install时,我收到以下提示:
$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.jso
n. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating autoload files



  [RuntimeException]
  Could not scan for classes inside "app/controllers/admin" which does not ap
  pear to be a file nor a folder



install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-p
lugins] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--ver
bose] [-o|--optimize-autoloader] [packages1] ... [packagesN]

这基本上是一个全新的Laravel安装。为什么我会收到错误提示:
Could not scan for classes inside "app/controllers/admin" which does not appear to be a file nor a folder

更新

使用composer update命令:

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing mockery/mockery (0.9.2)
  - Removing phpunit/phpunit (4.3.4)
  - Removing phpunit/php-code-coverage (2.0.11)
  - Removing phpunit/php-token-stream (1.3.0)
  - Removing phpunit/php-file-iterator (1.3.4)
  - Removing phpunit/php-timer (1.0.5)
  - Removing phpunit/phpunit-mock-objects (2.3.0)
  - Removing phpunit/php-text-template (1.2.0)
  - Removing doctrine/instantiator (1.0.4)
  - Removing symfony/yaml (v2.5.6)
  - Removing sebastian/comparator (1.0.1)
  - Removing sebastian/diff (1.2.0)
  - Removing sebastian/environment (1.2.0)
  - Removing sebastian/exporter (1.0.2)
  - Removing sebastian/version (1.0.3)
  - Removing summerstreet/woodling (v0.1.6)
Writing lock file
Generating autoload files



  [RuntimeException]
  Could not scan for classes inside "app/controllers/admin" which does not ap
  pear to be a file nor a folder



update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock]
 [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-
dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [
packagesN]
2个回答

1

尝试使用composer update命令。这就是错误信息中提示的方法。

...You may be getting outdated dependencies. Run update to update them...

更新:

Composer 正在尝试查找 app/controllers/admin 文件夹,但这不是 Laravel 中的标准文件夹。你确定这个文件夹存在吗?如果不存在,你可以尝试从 composer.json 中移除这些自定义文件夹,并手动添加它们。你也可以创建这些目录并保持 composer.json 不变。


谢谢你的回答!当运行composer update时,我得到了相同的错误,请看一下我的更新后的答案。 - Carol.Kar
你确定composer.json文件中的类文件夹存在吗?我已经更新了我的答案。 - Jerodev

1

对于2021年的Laravel 8,如果不存在admin文件夹,请在控制器中添加该文件夹,并且进入composer.json并将classmap进行更改。

  "classmap": [
        "app/http/controllers/admin"
    ]

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接