appengine 上的 Symfony3 会话失败

Symfony3 Session Failed on appengine

我想在 DB 上存储 Session,我在 symfony doc

中遵循了这个 link

在本地环境中我没有任何问题,但是当我在 appengine 上部署时我可以在日志中看到这个问题

2018-06-07 09:15:24 default[20180607t110053]  [07-Jun-2018 09:15:24] WARNING: [pool app] child 11 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /app/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php:403"
2018-06-07 09:15:24 default[20180607t110053]  [07-Jun-2018 09:15:24] WARNING: [pool app] child 11 said into stderr: "Stack trace:"
2018-06-07 09:15:24 default[20180607t110053]  [07-Jun-2018 09:15:24] WARNING: [pool app] child 11 said into stderr: "#0 /app/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php(403): PDO->__construct('mysql:host=;por...', 'root', 'MYPASS...', Array)"
2018-06-07 09:15:24 default[20180607t110053]  [07-Jun-2018 09:15:24] WARNING: [pool app] child 11 said into stderr: "#1 /app/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php(264): Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler->connect('mysql:host=;por...')"
2018-06-07 09:15:24 default[20180607t110053]  [07-Jun-2018 09:15:24] WARNING: [pool app] child 11 said into stderr: "#2 /app/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php(46): Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler->open('/tmp/sessions', 'PHPSESSID')"
2018-06-07 09:15:24 default[20180607t110053]  [07-Jun-2018 09:15:24] WARNING: [pool app] child 11 said into stderr: "#3 [internal function]: Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy->open('/tmp/sessions', 'PHP..."
2018-06-07 09:15:24 default[20180607t110053]  2018/06/07 09:15:24 [error] 9#9: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /app/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php:403
2018-06-07 09:15:24 default[20180607t110053]  Stack trace:
2018-06-07 09:15:24 default[20180607t110053]  #0 /app/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php(403): PDO->__construct('mysql:host=;por...', 'root', 'MYPASS...', Array)
2018-06-07 09:15:24 default[20180607t110053]  #1 /app/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php(264): Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler->connect('mysql:host=;por...')
2018-06-07 09:15:24 default[20180607t110053]  #2 /app/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php(46): Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler->open('/tmp/sessions', 'PHPSESSID')
2018-06-07 09:15:24 default[20180607t110053]  #3 [internal function]: Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy->open('/tmp/sessions', 'PHPSESSID')" while reading response header from upstream, client: 172.17.0.4, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "myproject.appspot.com"
2018-06-07 09:15:24 default[20180607t110053]  172.17.0.4 - - [07/Jun/2018:09:15:24 +0000] "GET / HTTP/1.1" 500 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36"

似乎主机mysql是空的

mysql:host=;

我建议您检查 yaml 文件中是否配置了主机,如 here. If that does not work, check this tutorial 所示,以便启动 Symphony 和 运行 在 App Engine 上。

也值得在此 thread by changing the database_host value. Similar troubleshooting posted here 上测试此故障排除。