我会尽可能简洁明了。我感谢所有帮助!
我的系统:Symfony 3.3.8 ,PHP 5.6.25。IDE:phpstorm
遇到错误: Attempted to load class "GuzzleBundle" from namespace "EightPointsBundleGuzzleBundle".
Did you forget a "use" statement for another namespace?
我的其他第三方捆绑包,knpmenu或fosuser,完美工作。
所有这些捆绑包已使用composer require
(Packagist),composer update
安装,然后在Appkernel中添加。
一旦我在appkernel中添加 new EightPointsBundleGuzzleBundleGuzzleBundle(),
,此错误就会在网站的每个页面上弹出。
我尝试在此过程后尝试使用composer dump-autoload
,但无济于事。我还在应用程序/confing/config.yml中添加了捆绑包配置。
这是我的文件:
appkernel.php
<?php
use SymfonyComponentHttpKernelKernel;
use SymfonyComponentConfigLoaderLoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new SymfonyBundleFrameworkBundleFrameworkBundle(),
new SymfonyBundleSecurityBundleSecurityBundle(),
new SymfonyBundleTwigBundleTwigBundle(),
new SymfonyBundleMonologBundleMonologBundle(),
new SymfonyBundleSwiftmailerBundleSwiftmailerBundle(),
new SymfonyBundleAsseticBundleAsseticBundle(),
new DoctrineBundleDoctrineBundleDoctrineBundle(),
new SensioBundleFrameworkExtraBundleSensioFrameworkExtraBundle(),
new EightPointsBundleGuzzleBundleGuzzleBundle(),
new KnpBundleMenuBundleKnpMenuBundle(),
new FOSUserBundleFOSUserBundle(),
new AppBundleAppBundle(),
new BaseBundleBaseBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new SymfonyBundleDebugBundleDebugBundle();
$bundles[] = new SymfonyBundleWebProfilerBundleWebProfilerBundle();
$bundles[] = new SensioBundleDistributionBundleSensioDistributionBundle();
if ('dev' === $this->getEnvironment()) {
$bundles[] = new SensioBundleGeneratorBundleSensioGeneratorBundle();
$bundles[] = new SymfonyBundleWebServerBundleWebServerBundle();
}
}
return $bundles;
}
public function getRootDir()
{
return __DIR__;
}
public function getCacheDir()
{
return dirname(__DIR__) . '/var/cache/' .$this->getEnvironment();
}
public function getLogDir()
{
return dirname(__DIR__) . '/var/logs';
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
composer.json
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The "Symfony Standard Edition" distribution",
"autoload": {
"psr-4": {
"AppBundle\": "src/AppBundle",
"BaseBundle\": "src/BaseBundle"
},
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"autoload-dev": {
"psr-4": { "Tests\": "tests/" },
"files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
},
"require": {
"php": ">=5.5.9",
"components/jquery": "^3.1",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"eightpoints/guzzle-bundle": "^6.1",
"friendsofsymfony/user-bundle": "~2.0",
"incenteev/composer-parameter-handler": "^2.0",
"knplabs/knp-menu-bundle": "^2.0",
"oyejorge/less.php": "v1.7.0.14",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/assetic-bundle": "^2.8",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/symfony": "3.3.8",
"twbs/bootstrap": "^3.3",
"twig/twig": "^1.0||^2.0"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
},
"scripts": {
"symfony-scripts": [
"Incenteev\ParameterHandler\ScriptHandler::buildParameters",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
],
"post-install-cmd": [
"@symfony-scripts"
],
"post-update-cmd": [
"@symfony-scripts"
]
},
"config": {
"platform": {
"php": "5.6.25"
},
"sort-packages": true
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "3.3-dev"
}
}
}
我不知道为什么我尝试使用此捆绑包时会遇到此错误,请帮助我!
错误解决。看起来像phpstorm不包括供应商文件夹。
因此,供应商没有上传到服务器(WAMP64/www)。顺便说一句,供应商在我本地的项目文件中。在服务器中完整上传供应商之后,一切似乎都起作用。
正常吗?我犯了一个开头错误吗?
谢谢您的四个快速帮助!