Symfony 2 - Fatal error: Cannot redeclare class SessionHandlerInterface in C:\…\app\cache\dev\classes.php on line 532

后端 未结 7 931
借酒劲吻你
借酒劲吻你 2020-12-11 00:38

After reinstalling my wamp environment this error message is showing on screen after I open app_dev.php:

Fatal error: Cannot redeclare class SessionHa

相关标签:
7条回答
  • 2020-12-11 01:05

    I was having caching issues even when using app_dev.php. I would change a route but it wouldn't update when I tried accessing it via a browser.

    I tried commenting out the anything that had cache in it (as stated above). None of that worked.

    If I ran the console cache:clear it would fix it, but the next routing change would break again. I had to run cache:clear with every save, which was ridiculous.

    My issue turned out that because I was working remotely over SFTP, PHP Storm (my editor) was "preserving timestamp" in its deployment configuration. Once I changed that configuration the issues went away. Apparently there is some caching going on that is looking at the file timestamps, even in the dev environment.

    0 讨论(0)
  • 2020-12-11 01:08

    I solved it clearing the cache:

    app/console cache:clear
    
    0 讨论(0)
  • 2020-12-11 01:12

    PHP version 5.4 introduced a new session management system based on an interface called SessionHandlerInterface and it would seem that your Symfony2 code declares a class with the very same name in the global namespace, so there is a name clash.

    Here are the docs: http://www.php.net/manual/en/class.sessionhandlerinterface.php

    SessionHandlerInterface is an interface which defines a prototype for creating a custom session handler. In order to pass a custom session handler to session_set_save_handler() using its OOP invocation, the class must implement this interface.

    0 讨论(0)
  • 2020-12-11 01:13

    Make sure you have defined namespace in your interface SessionHandlerInterface

    EX:

    namespace app\cache\dev;
    
    0 讨论(0)
  • 2020-12-11 01:20

    Only this worked for me rm -rf app/cache/*

    0 讨论(0)
  • 2020-12-11 01:26

    Just try to clear the Symfony2 cache with the one (or all) the commands below :

    php app/console cache:clear --env=prod --no-debug (on production mode)
    

    or / and

    php app/console cache:clear --env=dev --no-debug (on development mode)
    
    0 讨论(0)
提交回复
热议问题