Syhat PhpStorm Symfony中未定义的类常量

时间:2016-04-29 18:10:26

标签: symfony drupal phpstorm drupal-8

我正在尝试使用PhpStorm运行Behat测试,但我收到此错误:

未定义的类常量' Symfony \ Component \ DependencyInjection \ ContainerInterface :: SCOPE_CONTAINER'

我在this node中尝试了解决方案,但固定和更新Symfony版本并没有修复错误。

我正在使用Drupal 8.1运行Symfony 2.8

如果有帮助,这是堆栈跟踪:

PHP Stack trace:
    0.0011     475248   1. {main}() /home/vagrant/.phpstorm_helpers/behat.php:0
PHP   1. {main}() /home/vagrant/.phpstorm_helpers/behat.php:0
    0.0180    2831008   2. Symfony\Component\Console\Application->run() /home/vagrant/.phpstorm_helpers/behat.php:580
PHP   2. Symfony\Component\Console\Application->run() /home/vagrant/.phpstorm_helpers/behat.php:580
    0.0204    3206560   3. Behat\Testwork\Cli\Application->doRun() /home/vagrant/.composer/vendor/symfony/console/Application.php:117
PHP   3. Behat\Testwork\Cli\Application->doRun() /home/vagrant/.composer/vendor/symfony/console/Application.php:117
    0.2133   15751120   4. Symfony\Component\Console\Application->doRun() /home/vagrant/.composer/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:121
PHP   4. Symfony\Component\Console\Application->doRun() /home/vagrant/.composer/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:121
    0.2134   15752088   5. Symfony\Component\Console\Application->doRunCommand() /home/vagrant/.composer/vendor/symfony/console/Application.php:186
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/vagrant/.composer/vendor/symfony/console/Application.php:186
    0.2134   15752632   6. Symfony\Component\Console\Command\Command->run() /home/vagrant/.composer/vendor/symfony/console/Application.php:791
PHP   6. Symfony\Component\Console\Command\Command->run() /home/vagrant/.composer/vendor/symfony/console/Application.php:791
    0.2137   15758088   7. Behat\Testwork\Cli\Command->execute() /home/vagrant/.composer/vendor/symfony/console/Command/Command.php:256
PHP   7. Behat\Testwork\Cli\Command->execute() /home/vagrant/.composer/vendor/symfony/console/Command/Command.php:256
    0.2149   15870544   8. Behat\Testwork\Tester\Cli\ExerciseController->execute() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Cli/Command.php:63
PHP   8. Behat\Testwork\Tester\Cli\ExerciseController->execute() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Cli/Command.php:63
    0.2181   15960264   9. Behat\Testwork\Tester\Cli\ExerciseController->testSpecifications() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:108
PHP   9. Behat\Testwork\Tester\Cli\ExerciseController->testSpecifications() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:108
    0.2186   15985296  10. Behat\Testwork\Ordering\OrderedExercise->test() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:146
PHP  10. Behat\Testwork\Ordering\OrderedExercise->test() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Tester/Cli/ExerciseController.php:146
    0.2186   15985344  11. Behat\Testwork\EventDispatcher\Tester\EventDispatchingExercise->test() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Ordering/OrderedExercise.php:80
PHP  11. Behat\Testwork\EventDispatcher\Tester\EventDispatchingExercise->test() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Ordering/OrderedExercise.php:80
    0.2186   15985576  12. Behat\Testwork\Tester\Runtime\RuntimeExercise->test() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingExercise.php:70
PHP  12. Behat\Testwork\Tester\Runtime\RuntimeExercise->test() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingExercise.php:70
    0.2222   16810448  13. Behat\Testwork\EventDispatcher\Tester\EventDispatchingSuiteTester->setUp() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Tester/Runtime/RuntimeExercise.php:69
PHP  13. Behat\Testwork\EventDispatcher\Tester\EventDispatchingSuiteTester->setUp() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Tester/Runtime/RuntimeExercise.php:69
    0.2240   16823784  14. Behat\Testwork\Hook\Tester\HookableSuiteTester->setUp() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingSuiteTester.php:59
PHP  14. Behat\Testwork\Hook\Tester\HookableSuiteTester->setUp() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Tester/EventDispatchingSuiteTester.php:59
    0.2243   16839664  15. Behat\Testwork\Hook\HookDispatcher->dispatchScopeHooks() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Hook/Tester/HookableSuiteTester.php:63
PHP  15. Behat\Testwork\Hook\HookDispatcher->dispatchScopeHooks() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Hook/Tester/HookableSuiteTester.php:63
    0.2243   16839856  16. Behat\Testwork\Hook\HookRepository->getScopeHooks() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Hook/HookDispatcher.php:57
PHP  16. Behat\Testwork\Hook\HookRepository->getScopeHooks() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Hook/HookDispatcher.php:57
    0.2244   16839944  17. Behat\Testwork\Hook\HookRepository->getEnvironmentHooks() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Hook/HookRepository.php:67
PHP  17. Behat\Testwork\Hook\HookRepository->getEnvironmentHooks() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Hook/HookRepository.php:67
    0.2244   16840016  18. Behat\Testwork\Environment\EnvironmentManager->readEnvironmentCallees() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Hook/HookRepository.php:50
PHP  18. Behat\Testwork\Environment\EnvironmentManager->readEnvironmentCallees() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Hook/HookRepository.php:50
    0.2625   17611832  19. Drupal\DrupalExtension\Context\Environment\Reader\Reader->readEnvironmentCallees() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Environment/EnvironmentManager.php:115

PHP  19. Drupal\DrupalExtension\Context\Environment\Reader\Reader->readEnvironmentCallees() /var/www/drupalvm/vendor/behat/behat/src/Behat/Testwork/Environment/EnvironmentManager.php:115
    0.2625   17612192  20. Drupal\DrupalExtension\Context\Environment\Reader\Reader->findSubContextClasses() /var/www/drupalvm/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Context/Environment/Reader/Reader.php:90    0.2625   17612656  21. Drupal\Driver\DrupalDriver->getSubDriverPaths() /var/www/drupalvm/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Context/Environment/Reader/Reader.php:139
PHP  20. Drupal\DrupalExtension\Context\Environment\Reader\Reader->findSubContextClasses() /var/www/drupalvm/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Context/Environment/Reader/Reader.php:90
    0.2625   17612760  22. Drupal\Driver\DrupalDriver->bootstrap() /home/vagrant/.composer/vendor/drupal/drupal-driver/src/Drupal/Driver/DrupalDriver.php:140
PHP  21. Drupal\Driver\DrupalDriver->getSubDriverPaths() /var/www/drupalvm/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Context/Environment/Reader/Reader.php:139

    0.2625   17612984  23. Drupal\Driver\Cores\Drupal8->bootstrap() /home/vagrant/.composer/vendor/drupal/drupal-driver/src/Drupal/Driver/DrupalDriver.php:80PHP  22. Drupal\Driver\DrupalDriver->bootstrap() /home/vagrant/.composer/vendor/drupal/drupal-driver/src/Drupal/Driver/DrupalDriver.php:140
PHP  23. Drupal\Driver\Cores\Drupal8->bootstrap() /home/vagrant/.composer/vendor/drupal/drupal-driver/src/Drupal/Driver/DrupalDriver.php:80
    0.2685   18876368  24. Drupal\Core\DrupalKernel->boot() /var/www/drupalvm/vendor/drupal/drupal-driver/src/Drupal/Driver/Cores/Drupal8.php:37
PHP  24. Drupal\Core\DrupalKernel->boot() /var/www/drupalvm/vendor/drupal/drupal-driver/src/Drupal/Driver/Cores/Drupal8.php:37
    0.2697   19119592  25. Drupal\Core\DrupalKernel->initializeContainer() /var/www/drupalvm/core/lib/Drupal/Core/DrupalKernel.php:435
PHP  25. Drupal\Core\DrupalKernel->initializeContainer() /var/www/drupalvm/core/lib/Drupal/Core/DrupalKernel.php:435
    0.2746   20182344  26. Drupal\Core\DrupalKernel->attachSynthetic() /var/www/drupalvm/core/lib/Drupal/Core/DrupalKernel.php:833

PHP  26. Drupal\Core\DrupalKernel->attachSynthetic() /var/www/drupalvm/core/lib/Drupal/Core/DrupalKernel.php:833

Process finished with exit code 255
    0.2748   20226904  27. Drupal\Core\DependencyInjection\Container->set() /var/www/drupalvm/core/lib/Drupal/Core/DrupalKernel.php:1090

PHP  27. Drupal\Core\DependencyInjection\Container->set() /var/www/drupalvm/core/lib/Drupal/Core/DrupalKernel.php:1090
Empty test suite.

感谢您的任何意见。

EDIT ::   当我在我的VM中执行作曲家信息时,这就是我的版本的样子

symfony/browser-kit                  v2.7.6  Symfony BrowserKit Component
symfony/class-loader                 v2.8.4  Symfony ClassLoader Component
symfony/config                       v3.0.4  Symfony Config Component
symfony/console                      v2.8.4  Symfony Console Component
symfony/css-selector                 v2.8.4  Symfony CssSelector Component
symfony/debug                        v2.7.6  Symfony Debug Component
symfony/dependency-injection         v2.8.4  Symfony DependencyInjection     Component
symfony/dom-crawler                  v2.7.6  Symfony DomCrawler Component
symfony/event-dispatcher             v2.8.4  Symfony EventDispatcher Component
symfony/filesystem                   v3.0.4  Symfony Filesystem Component
symfony/http-foundation              v2.8.4  Symfony HttpFoundation Component
symfony/http-kernel                  v2.8.4  Symfony HttpKernel Component
symfony/polyfill-apcu                v1.1.1  Symfony polyfill backporting   apcu_* functions to lower PHP versions
symfony/polyfill-iconv               v1.1.1  Symfony polyfill for the Iconv extension
symfony/polyfill-mbstring            v1.1.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php54               v1.1.0  Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55               v1.1.0  Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/process                      v2.8.4  Symfony Process Component
symfony/psr-http-message-bridge      v0.2    PSR HTTP message bridge
symfony/routing                      v2.8.4  Symfony Routing Component
symfony/serializer                   v2.8.4  Symfony Serializer Component
symfony/translation                  v2.8.4  Symfony Translation Component
symfony/validator                    v2.8.4  Symfony Validator Component
symfony/yaml                         v2.8.4  Symfony Yaml Component

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题,在composer.json中添加了特定版本的symfony组件for behat。

    "symfony/dependency-injection": "2.8.2"
    "symfony/event-dispatcher": "2.8.2"

我的composer.json看起来像这样

{
    "require": {
        "symfony/dependency-injection": "2.8.2",
        "symfony/event-dispatcher": "2.8.2",
        "drupal/drupal-extension": "~3.0",
        "guzzlehttp/guzzle" : "^6.0@dev",
        "drupal/drupal-driver": "~1.0",
        "behat/behat": "^3.1",
        "behat/mink": "^1.7",
        "behat/mink-extension": "^2.2",
        "behat/mink-selenium2-driver": "^1.3",
        "behat/mink-goutte-driver": "^1.2",
        "beberlei/assert": "^2.5"
    },
    "config": {
        "bin-dir": "bin/"
    }
}

希望这有帮助