像包不存在一样突出显示导入(Symfony 4)

时间:2018-06-26 08:18:37

标签: symfony phpstorm symfony4 phpstorm-2018.1

我正在使用PhpStorm 2018.1进行Symfony 4项目

对于我来说,看到use声明被突出显示,就像没有在作曲家中安装它们一样,已经很普遍了。

  

该类属于您的包中不需要的包   composer.json。请将软件包添加到您的composer.json中。

以下内容已安装并显示在我的composer.json文件中:

  • stof/doctrine-extensions-bundle
  • symfony/orm-pack

我在这里错过了什么吗?还是PhpStorm问题?

enter image description here

composer.json

{
    "type": "project",
    "license": "proprietary",
    "platform": {
        "php": "7.1"
    },
    "require": {
        "php": "^7.1",
        "ext-iconv": "*",
        "sensio/framework-extra-bundle": "^5.1",
        "stof/doctrine-extensions-bundle": "^1.3",
        "symfony/asset": "^4.1",
        "symfony/console": "^4.1",
        "symfony/expression-language": "^4.1",
        "symfony/flex": "^1.0",
        "symfony/form": "^4.1",
        "symfony/framework-bundle": "^4.1",
        "symfony/lts": "^4@dev",
        "symfony/maker-bundle": "^1.5",
        "symfony/monolog-bundle": "^3.3",
        "symfony/orm-pack": "^1.0",
        "symfony/process": "^4.1",
        "symfony/profiler-pack": "^1.0",
        "symfony/security-bundle": "^4.1",
        "symfony/security-guard": "^4.1",
        "symfony/serializer-pack": "*",
        "symfony/swiftmailer-bundle": "^3.1",
        "symfony/twig-bundle": "^4.1",
        "symfony/validator": "^4.1",
        "symfony/var-dumper": "^4.1",
        "symfony/web-link": "^4.1",
        "symfony/webpack-encore-pack": "^1.0",
        "symfony/yaml": "^4.1"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.0",
        "symfony/debug-pack": "*",
        "symfony/dotenv": "^4.1",
        "symfony/test-pack": "^1.0",
        "symfony/web-server-bundle": "^4.1"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": true
        }
    }
}

2 个答案:

答案 0 :(得分:2)

此消息告诉您的是,突出显示的类仅可用,因为包含它们的软件包已作为您需要的某些其他软件包的依赖项安装(在这种情况下,可能是由于symfony/orm-pack软件包所致)。通常,依靠这种传递依赖关系不是我要做的事情。尽管对于Symfony包,这是IMO可以接受的。

如果您仍然担心此消息,可以通过解压缩symfony/orm-pack(另请参阅http://fabien.potencier.org/symfony4-unpack-the-packs.html)来消除此消息:

$ composer unpack symfony/orm-pack

答案 1 :(得分:0)

您的导入路径正确,您的composer.json也看起来不错。

尝试删除vendor目录,然后尝试启动composer install

尝试在您的PHPStorm中安装Symfony Plugin

编辑

您的config/bundles.php中是否有以下行?

Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],