6

After a php update from 5.6 to 7, Symfony 3 raise this exception:

Fatal error: Class Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::write) in \vendor\symfony\symfony\src\Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy.php on line 19

is Symfony 3 incompatible with PHP 7? same code work on php 5.6

composer show -i output:

doctrine/annotations                 v1.2.7  Docblock Annotations Parser
doctrine/cache                       v1.6.0  Caching library offering an o...
doctrine/collections                 v1.3.0  Collections Abstraction library
doctrine/common                      v2.6.1  Common Library for Doctrine p...
doctrine/dbal                        v2.5.3  Database Abstraction Layer
doctrine/doctrine-bundle             1.6.1   Symfony DoctrineBundle
doctrine/doctrine-cache-bundle       1.2.2   Symfony Bundle for Doctrine C...
doctrine/inflector                   v1.1.0  Common String Manipulations w...
doctrine/instantiator                1.0.5   A small, lightweight utility ...
doctrine/lexer                       v1.0.1  Base library for a lexer that...
doctrine/orm                         v2.5.3  Object-Relational-Mapper for PHP
incenteev/composer-parameter-handler v2.1.2  Composer script handling your...
jdorn/sql-formatter                  v1.2.17 a PHP SQL highlighting library
kriswallsmith/assetic                v1.3.2  Asset Management for PHP
monolog/monolog                      1.17.2  Sends your logs to files, soc...
paragonie/random_compat              v1.2.2  PHP 5.x polyfill for random_b...
psr/log                              1.0.0   Common interface for logging ...
sensio/distribution-bundle           v5.0.3  Base bundle for Symfony Distr...
sensio/framework-extra-bundle        v3.0.12 This bundle provides a way to...
sensio/generator-bundle              v3.0.3  This bundle generates code fo...
sensiolabs/security-checker          v3.0.2  A security checker for your c...
swiftmailer/swiftmailer              v5.4.1  Swiftmailer, free feature-ric...
symfony/assetic-bundle               v2.7.1  Integrates Assetic into Symfony2
symfony/monolog-bundle               v2.8.2  Symfony MonologBundle
symfony/phpunit-bridge               v2.8.1  Symfony PHPUnit Bridge
symfony/polyfill-intl-icu            v1.1.1  Symfony polyfill for intl's I...
symfony/polyfill-mbstring            v1.1.1  Symfony polyfill for the Mbst...
symfony/polyfill-php56               v1.1.1  Symfony polyfill backporting ...
symfony/polyfill-php70               v1.1.1  Symfony polyfill backporting ...
symfony/polyfill-util                v1.1.1  Symfony utilities for portabi...
symfony/swiftmailer-bundle           v2.3.9  Symfony SwiftmailerBundle
symfony/symfony                      v3.0.3  The Symfony PHP framework
twig/twig                            v1.24.0 Twig, the flexible, fast, and...

php.ini

[opcache]
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=6000
opcache.use_cwd=1
opcache.validate_timestamps=1
opcache.save_comments=1
opcache.fast_shutdown=1
ar099968
  • 6,963
  • 12
  • 64
  • 127
  • Please show the output of `composer show -i` – Emii Khaos Mar 18 '16 at 16:29
  • @PatrikKarisch i have updated the question – ar099968 Mar 18 '16 at 17:19
  • 1
    Do you use Opcache and need to flush it? Also make sure that you do not share the same Opcache across several projects as they may then interfer. – xabbuh Mar 19 '16 at 09:09
  • 1
    Also check that you're running on the newest version of PHP 7 (7.0.4). I remember a bug that manifested similar to this being fixed in an earlier version. – NikiC Mar 19 '16 at 10:03
  • 1
    @xabbuh yes, i use opcache. If i disable opcache all work. The project is alone on the server (not Opcache sharing) – ar099968 Mar 21 '16 at 11:53
  • @NikiC i have tried 7.0.4 and 7.0.5RC1 the problem persist. – ar099968 Mar 21 '16 at 11:54
  • Try running with opcache.protect_memory=1 and see if you get a segfault. – NikiC Mar 21 '16 at 17:24
  • @NikiC error persist. – ar099968 Mar 22 '16 at 07:55
  • I get the same error under the same conditions with Symfony 2.8.3. If I restart Apache it seems to clear it up. – Jason Hanley Apr 04 '16 at 19:47
  • @JasonHanley yep! i think this is a opcache issue... – ar099968 Apr 05 '16 at 06:50
  • Have you tried deleting `app/cache/*` and then running `app/console c:c`? Maybe it's some old SF cache – thormeier Jun 10 '16 at 13:21
  • yes.. error persists on "PHP 7 - Windows" – ar099968 Jun 10 '16 at 14:25
  • same error for me occurs on Laravel. I am using symphony's native session driver instead of laravel's drivers and if i restart apache it solves for me too. its on windows php 7.0.10 and opcache is not enabled for me. – Yousaf Aug 31 '16 at 20:10
  • 1
    I've just had this issue with 3.1 using PHP 7 on my local machine. I switched to 5.6 and it worked again. So I turned it back to 7 to see if it was still broken, but it went back to working fine. I'm currently using WAMP on a windows 10 machine. I think it's definitely to do with the opcache, restarting apache/switching versions seems ot be fixing it when it's come up. – Scott Flack Oct 24 '16 at 03:48

2 Answers2

13

Restarting the httpd services can clear this error.

Have not been able to reproduce the error after experiencing it but it could be a PHP crash that in turn causes an incomplete state that makes the error message get stuck in the buffer response of the httpd service, it is then served for every single request to any vhost being served on that service from then on until the service is killed.

Credit Scott Flacks comment in the other answer.

Marc
  • 5,109
  • 2
  • 32
  • 41
  • 2
    Following this solution I restarted Xampp and everything was ok. – Mz1907 Jul 22 '17 at 15:50
  • worked for me, this makes me worried about the production enviroment, especially that we do not know what happened. – Motassem Kassab Nov 27 '17 at 19:58
  • Worries me that it is possible that content buffer output can get stuck with a specific content in buffer and spit that out publicly for every single request. What if it crashed while rendering sensitive information... – Marc Jan 08 '18 at 13:42
  • In Windows environment smetimes a stack (WAMP, LAMP, XAMP, etc) restart solves a lot of problem, especially with file loading or reading issues. – Sentence May 16 '19 at 12:21
0

Try upgrading to Symfony 3.1.

Symfony 3.0 was released in Nov 2015 and though it should be compatible with PHP7 -- PHP7 was officially released only later, in Dec 2015.

Andy
  • 4,901
  • 5
  • 35
  • 57
Eeko
  • 106
  • 9