作曲家自动加载器不工作

Composer autoloader not working

我会尽可能简明扼要。感谢所有的帮助!

我的系统:Symfony 3.3.8, PHP 5.6.25。 IDE:PhpStorm

遇到错误Attempted to load class "GuzzleBundle" from namespace "EightPoints\Bundle\GuzzleBundle". Did you forget a "use" statement for another namespace?

我的其他第三方包,KnPMenu 或 FOSUser,运行完美。

所有这些包都已使用 composer require (packagist)、composer update 安装,然后添加到 AppKernel 中。

我在 AppKernel 添加 new EightPoints\Bundle\GuzzleBundle\GuzzleBundle(), 后,网站的每个页面都会弹出此错误。

我在这个过程之后尝试composer dump-autoload,但无济于事。我还在 app/confing/config.yml.

中添加了包配置

这是我的文件:

AppKernel.php

<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new EightPoints\Bundle\GuzzleBundle\GuzzleBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            new AppBundle\AppBundle(),
            new BaseBundle\BaseBundle(),
    ];
    if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
        $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
        $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
        $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
        if ('dev' === $this->getEnvironment()) {
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
            $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
        }
    }
    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)。 顺便说一句,供应商在我的本地项目文件中……可悲的是。 在服务器中完整上传供应商后,一切似乎都正常。

正常吗?我犯了初学者的错误吗?

非常感谢您的四个快速帮助!