Symfony 2.6 & php7.1 fixe composer install

Dernièrement je suis passé en php7.1 avec un projet Symfony 2.6 et j’ai eu quelques soucis lors de l’utilisation de composer install et composer update. Un conflit dans la gestion des modules de php avec opcache et le bundle sensio/distribution-bundle.

1
2
3
4
5
6
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
Cannot load Zend OPcache - it was already loaded
PHP Warning: Module 'mysqlnd' already loaded in Unknown on line 0
PHP Warning: Module 'PDO' already loaded in Unknown on line 0
PHP Warning: Module 'xml' already loaded in Unknown on line 0
...

Log Error Detail

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
Cannot load Zend OPcache - it was already loaded
PHP Warning: Module 'mysqlnd' already loaded in Unknown on line 0
PHP Warning: Module 'PDO' already loaded in Unknown on line 0
PHP Warning: Module 'xml' already loaded in Unknown on line 0
PHP Warning: Module 'calendar' already loaded in Unknown on line 0
PHP Warning: Module 'ctype' already loaded in Unknown on line 0
PHP Warning: Module 'curl' already loaded in Unknown on line 0
PHP Warning: Module 'dom' already loaded in Unknown on line 0
PHP Warning: Module 'exif' already loaded in Unknown on line 0
PHP Warning: Module 'fileinfo' already loaded in Unknown on line 0
PHP Warning: Module 'ftp' already loaded in Unknown on line 0
PHP Warning: Module 'gd' already loaded in Unknown on line 0
PHP Warning: Module 'gettext' already loaded in Unknown on line 0
PHP Warning: Module 'iconv' already loaded in Unknown on line 0
PHP Warning: Module 'json' already loaded in Unknown on line 0
PHP Warning: Module 'mbstring' already loaded in Unknown on line 0
PHP Warning: Module 'mcrypt' already loaded in Unknown on line 0
PHP Warning: Module 'mysqli' already loaded in Unknown on line 0
PHP Warning: Module 'pdo_mysql' already loaded in Unknown on line 0
PHP Warning: Module 'pdo_sqlite' already loaded in Unknown on line 0
PHP Warning: Module 'Phar' already loaded in Unknown on line 0
PHP Warning: Module 'posix' already loaded in Unknown on line 0
PHP Warning: Module 'readline' already loaded in Unknown on line 0
PHP Warning: Module 'shmop' already loaded in Unknown on line 0
PHP Warning: Module 'SimpleXML' already loaded in Unknown on line 0
PHP Warning: Module 'sockets' already loaded in Unknown on line 0
PHP Warning: Module 'sqlite3' already loaded in Unknown on line 0
PHP Warning: Module 'sysvmsg' already loaded in Unknown on line 0
PHP Warning: Module 'sysvsem' already loaded in Unknown on line 0
PHP Warning: Module 'sysvshm' already loaded in Unknown on line 0
PHP Warning: Module 'tokenizer' already loaded in Unknown on line 0
PHP Warning: Module 'wddx' already loaded in Unknown on line 0
PHP Warning: Module 'xmlreader' already loaded in Unknown on line 0
PHP Warning: Module 'xmlwriter' already loaded in Unknown on line 0
PHP Warning: Module 'xsl' already loaded in Unknown on line 0
PHP Warning: Module 'zip' already loaded in Unknown on line 0
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
Cannot load Zend OPcache - it was already loaded
PHP Warning: Module 'mysqlnd' already loaded in Unknown on line 0
PHP Warning: Module 'PDO' already loaded in Unknown on line 0
PHP Warning: Module 'xml' already loaded in Unknown on line 0
PHP Warning: Module 'calendar' already loaded in Unknown on line 0
PHP Warning: Module 'ctype' already loaded in Unknown on line 0
PHP Warning: Module 'curl' already loaded in Unknown on line 0
PHP Warning: Module 'dom' already loaded in Unknown on line 0
PHP Warning: Module 'exif' already loaded in Unknown on line 0
PHP Warning: Module 'fileinfo' already loaded in Unknown on line 0
PHP Warning: Module 'ftp' already loaded in Unknown on line 0
PHP Warning: Module 'gd' already loaded in Unknown on line 0
PHP Warning: Module 'gettext' already loaded in Unknown on line 0
PHP Warning: Module 'iconv' already loaded in Unknown on line 0
PHP Warning: Module 'json' already loaded in Unknown on line 0
PHP Warning: Module 'mbstring' already loaded in Unknown on line 0
PHP Warning: Module 'mcrypt' already loaded in Unknown on line 0
PHP Warning: Module 'mysqli' already loaded in Unknown on line 0
PHP Warning: Module 'pdo_mysql' already loaded in Unknown on line 0
PHP Warning: Module 'pdo_sqlite' already loaded in Unknown on line 0
PHP Warning: Module 'Phar' already loaded in Unknown on line 0
PHP Warning: Module 'posix' already loaded in Unknown on line 0
PHP Warning: Module 'readline' already loaded in Unknown on line 0
PHP Warning: Module 'shmop' already loaded in Unknown on line 0
PHP Warning: Module 'SimpleXML' already loaded in Unknown on line 0
PHP Warning: Module 'sockets' already loaded in Unknown on line 0
PHP Warning: Module 'sqlite3' already loaded in Unknown on line 0
PHP Warning: Module 'sysvmsg' already loaded in Unknown on line 0
PHP Warning: Module 'sysvsem' already loaded in Unknown on line 0
PHP Warning: Module 'sysvshm' already loaded in Unknown on line 0
PHP Warning: Module 'tokenizer' already loaded in Unknown on line 0
PHP Warning: Module 'wddx' already loaded in Unknown on line 0
PHP Warning: Module 'xmlreader' already loaded in Unknown on line 0
PHP Warning: Module 'xmlwriter' already loaded in Unknown on line 0
PHP Warning: Module 'xsl' already loaded in Unknown on line 0
PHP Warning: Module 'zip' already loaded in Unknown on line 0


[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
Unable to parse file "/var/www/TestAPI/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/../Resources/config/web.xml".


[InvalidArgumentException]
The XML file "/var/www/TestAPI/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/../Resources/config/web.xml" is not valid.


[Symfony\Component\Debug\Exception\ContextErrorException]
Notice: Undefined property: DOMDocument::$documentElement

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception

In ScriptHandler.php line 439:

An error occurred when executing the "'cache:clear --no-warmup'" command:

Cannot load Zend OPcache - it was already loaded
PHP Warning: Module 'mysqlnd' already loaded in Unknown on line 0
PHP Warning: Module 'PDO' already loaded in Unknown on line 0
PHP Warning: Module 'xml' already loaded in Unknown on line 0
PHP Warning: Module 'calendar' already loaded in Unknown on line 0
PHP Warning: Module 'ctype' already loaded in Unknown on line 0
PHP Warning: Module 'curl' already loaded in Unknown on line 0
PHP Warning: Module 'dom' already loaded in Unknown on line 0
PHP Warning: Module 'exif' already loaded in Unknown on line 0
PHP Warning: Module 'fileinfo' already loaded in Unknown on line 0
PHP Warning: Module 'ftp' already loaded in Unknown on line 0
PHP Warning: Module 'gd' already loaded in Unknown on line 0
PHP Warning: Module 'gettext' already loaded in Unknown on line 0
PHP Warning: Module 'iconv' already loaded in Unknown on line 0
PHP Warning: Module 'json' already loaded in Unknown on line 0
PHP Warning: Module 'mbstring' already loaded in Unknown on line 0
PHP Warning: Module 'mcrypt' already loaded in Unknown on line 0
PHP Warning: Module 'mysqli' already loaded in Unknown on line 0
PHP Warning: Module 'pdo_mysql' already loaded in Unknown on line 0
PHP Warning: Module 'pdo_sqlite' already loaded in Unknown on line 0
PHP Warning: Module 'Phar' already loaded in Unknown on line 0
PHP Warning: Module 'posix' already loaded in Unknown on line 0
PHP Warning: Module 'readline' already loaded in Unknown on line 0
PHP Warning: Module 'shmop' already loaded in Unknown on line 0
PHP Warning: Module 'SimpleXML' already loaded in Unknown on line 0
PHP Warning: Module 'sockets' already loaded in Unknown on line 0
PHP Warning: Module 'sqlite3' already loaded in Unknown on line 0
PHP Warning: Module 'sysvmsg' already loaded in Unknown on line 0
PHP Warning: Module 'sysvsem' already loaded in Unknown on line 0
PHP Warning: Module 'sysvshm' already loaded in Unknown on line 0
PHP Warning: Module 'tokenizer' already loaded in Unknown on line 0
PHP Warning: Module 'wddx' already loaded in Unknown on line 0
PHP Warning: Module 'xmlreader' already loaded in Unknown on line 0
PHP Warning: Module 'xmlwriter' already loaded in Unknown on line 0
PHP Warning: Module 'xsl' already loaded in Unknown on line 0
PHP Warning: Module 'zip' already loaded in Unknown on line 0


[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
Unable to parse file "/var/www/TestAPI/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/../Resources/config/web.xml".


[InvalidArgumentException]
The XML file "/var/www/TestAPI/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/../Resources/config/web.xml" is not valid.


[Symfony\Component\Debug\Exception\ContextErrorException]
Notice: Undefined property: DOMDocument::$documentElement


Le problème ce trouve dans le fichier ScriptHandler.php dans vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php’

Vous devez modifié (ligne 553):

1
2
3
if (false !== $ini = php_ini_loaded_file()) {
$arguments[] = '--php-ini='.$ini;
}

par

1
2
3
4
5
6
7
8
9
if ($env = strval(getenv('COMPOSER_ORIGINAL_INIS'))) {
$paths = explode(PATH_SEPARATOR, $env);
$ini = array_shift($paths);
} else {
$ini = php_ini_loaded_file();
}
if (!empty($ini)) {
$arguments[] = '--php-ini='.$ini;
}

Une autre solution serait de passer sensio/distribution-bundle à la version 5.* mais c’est une autre histoire.

Lien vers l’issue Github