symfony: YamlFileLoader - Undefined class constant 'PARSE_CONSTANT'
Hi, I found this behavior on Symfony dev version for 3.2.
Problem is in file Symfony/Component/DependencyInjection/Loader/YamlFileLoader on line 396. There is PHP no able to get constant PARSE_CONSTANT (see in error log).
try {
$configuration = $this->yamlParser->parse(file_get_contents($file), Yaml::PARSE_CONSTANT);
} catch (ParseException $e) {
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $file), 0, $e);
}
Error: Undefined class constant 'PARSE_CONSTANT'
/home/travis/build/Tabetha/JMSTranslationBundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php:396
/home/travis/build/Tabetha/JMSTranslationBundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php:69
/home/travis/build/Tabetha/JMSTranslationBundle/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/DelegatingLoader.php:45
/home/travis/build/Tabetha/JMSTranslationBundle/Tests/Functional/AppKernel.php:61
/home/travis/build/Tabetha/JMSTranslationBundle/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:571
/home/travis/build/Tabetha/JMSTranslationBundle/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:484
/home/travis/build/Tabetha/JMSTranslationBundle/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:117
/home/travis/build/Tabetha/JMSTranslationBundle/Tests/Functional/Command/BaseCommandTestCase.php:29
/home/travis/build/Tabetha/JMSTranslationBundle/Tests/Functional/Command/ExtractCommandTest.php:55
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (9 by maintainers)
Commits related to this issue
- Don't use phar archive of phpunit (https://github.com/symfony/symfony/issues/19532#issuecomment-266307266) — committed to 1up-lab/OneupUploaderBundle by bytehead 8 years ago
@sebastianlp the solution is to not use the PHPUnit PHAR and instead, do a Composer + require-dev + phpunit/phpunit and execute your tests via
./vendor/bin/phpunit
(or./bin/phpunit
depending on your Symfony config).The even better solution is to require Symfony’s php unit bridge and use the simple-phpunit wrapper instead.
To reproduce this install phpunit 4.8, and run the following test:
As nicolas-grekas said, this is because phpunit comes with its own version of the Yaml component, which is loaded before the version you use in the project.
There’s not much we can do about it.