gpt4 book ai didi

php - 试图从命名空间 "WebpackEncoreBundle"加载类 "Symfony\WebpackEncoreBundle"。您是否忘记了另一个命名空间的 "use"语句?

转载 作者:行者123 更新时间:2023-12-05 05:10:10 28 4
gpt4 key购买 nike

我有一个奇怪的问题。我使用 Symfony Flex 并处理现有项目。我尝试使用以下命令安装 webpack-encore-bundle:

composer require symfony/webpack-encore-bundle

然后我明白了:

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.2.*"
Package operations: 1 install, 0 updates, 0 removals
- Installing symfony/webpack-encore-bundle (v1.6.2): Loading from cache
Package symfony/webpack-encore-pack is abandoned, you should avoid using it. Use symfony/webpack-encore-bundle instead.
Writing lock file
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 1 recipe (8e557491367cda509fceebb187833635)
- Configuring symfony/webpack-encore-bundle (>=1.0): From github.com/symfony/recipes:master
Executing script cache:clear [OK]
Executing script assets:install --symlink --relative public [OK]

Some files may have been created or updated to configure your new packages.
Please review, edit and commit them: these files are yours.

然后我运行:

yarn install

我明白了:

    yarn install v1.16.0
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > sass-loader@7.1.0" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 2.39s.

一切似乎都很好。现在我刷新项目并得到这个:

ClassNotFoundException

Attempted to load class "WebpackEncoreBundle" from namespace "Symfony\WebpackEncoreBundle".
Did you forget a "use" statement for another namespace?

所以这是我在 bundles.php 中的内容:

Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],

在 composer.json 我有:

"autoload": {
"psr-4": {
"App\\": "src/"
}
},

我跑:

yarn encore dev

编译成功了,但是我也有同样的错误。

我也试过这个命令:

composer remove symfony/webpack-encore-bundle

那我再试试

composer require symfony/webpack-encore-bundle

然后我们得到了同样的错误,这个循环永远不会结束。

最佳答案

我有这个错误,我只是通过安装 webpack-encore-bundle 修复了它:

composer require symfony/webpack-encore-bundle

在我的例子中,我必须在 webpack-encore-bundle 之前安装 doctrine-orm-admin-bundle:

composer require sonata-project/doctrine-orm-admin-bundle

关于php - 试图从命名空间 "WebpackEncoreBundle"加载类 "Symfony\WebpackEncoreBundle"。您是否忘记了另一个命名空间的 "use"语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56950621/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com