【发布时间】:2021-08-22 00:32:59
【问题描述】:
我正在学习 Symfony,
我创建我的项目:symfony new myproject --full
在此之后我直接运行symfony serve
在控制台中我收到了这些错误:
Tailing Web Server log file (/Users/ben/.symfony/log/cd52af540b09d661e4ffb4f5029da4bbaf3586a9.log)
Tailing PHP-FPM log file (/Users/ben/.symfony/log/cd52af540b09d661e4ffb4f5029da4bbaf3586a9/53fb8ec204547646acb3461995e4da5a54cc7575.log)
[OK] Web server listening
The Web server is using PHP FPM 7.3.11
https://127.0.0.1:8000
[Web Server ] Jun 3 23:38:48 |DEBUG | PHP Reloading PHP versions
[Web Server ] Jun 3 23:38:48 |DEBUG | PHP Using PHP version 7.3.11 (from default version in $PATH)
[Application] Jun 3 21:29:59 |CRITICA| REQUES Uncaught PHP Exception Doctrine\DBAL\Exception\ConnectionException: "An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?" at /Users/ben/Desktop/symfonytuto/demo/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 96
[Application] Jun 3 21:29:59 |CRITICA| REQUES Exception thrown when handling an exception (Doctrine\DBAL\Exception\ConnectionException: An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432? at /Users/ben/Desktop/symfonytuto/demo/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 96)
[Application] Jun 3 21:29:59 |CRITICA| PHP Uncaught Exception: An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
[Application] Jun 3 21:37:59 |ERROR | REQUES Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET https://127.0.0.1:8000/"" at /Users/ben/Desktop/symfonytuto/demo/vendor/symfony/http-kernel/EventListener/RouterListener.php line 136
[Application] Jun 3 21:38:00 |ERROR | REQUES Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET https://127.0.0.1:8000/favicon.ico" (from "https://127.0.0.1:8000/")" at /Users/ben/Desktop/symfonytuto/demo/vendor/symfony/http-kernel/EventListener/RouterListener.php line 136
[Application] Jun 3 21:38:00 |CRITICA| REQUES Exception thrown when handling an exception (Doctrine\DBAL\Exception\ConnectionException: An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432? at /Users/ben/Desktop/symfonytuto/demo/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 96)
[Application] Jun 3 21:38:00 |CRITICA| PHP Uncaught Exception: An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
[Application] Jun 3 21:38:00 |CRITICA| REQUES Uncaught PHP Exception Doctrine\DBAL\Exception\ConnectionException: "An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?" at /Users/ben/Desktop/symfonytuto/demo/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 96
[Application] Jun 3 21:38:00 |CRITICA| REQUES Exception thrown when handling an exception (Doctrine\DBAL\Exception\ConnectionException: An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432? at /Users/ben/Desktop/symfonytuto/demo/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php line 96)
[Application] Jun 3 21:38:00 |CRITICA| PHP Uncaught Exception: An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
[Web Server ] Jun 3 23:38:48 |INFO | PHP listening path="/usr/sbin/php-fpm" php="7.3.11" port=50170
[PHP-FPM ] Jun 3 23:38:48 |NOTICE | FPM fpm is running, pid 1240
[PHP-FPM ] Jun 3 23:38:48 |NOTICE | FPM ready to handle connections
在此之后 Symfony 的默认页面加载正确,但是当我添加到 url 的路由时,例如:https://127.0.0.1:8000/testtt
我收到此错误:
An exception occurred in driver: SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
(应该是“这条路线不存在”之类的吧?)
请告诉我如何为您提供有关我的问题的更多信息!
非常感谢!
【问题讨论】:
-
Doctrine Migrations Bundle 需要在开发模式下为配置文件栏建立一个实际的数据库连接。删除捆绑包(如果需要,可以稍后重新安装)或创建数据库并调整凭据。顺便说一句,当没有定义路由时,会出现您所谓的“默认页面”。一旦你定义了一个,你就会开始得到这些类型的错误。
-
嗨@Cerad 谢谢你的回答,我在 Udemy.com 上学习 Symfony 课程,他没有创建任何数据库,或者删除了一个包,他的错误是“这条路线不存在”或其他什么像那样..所以很奇怪我必须做他没有做的事情才能正常工作..但是如果别无选择,请给我有关您的解决方案的更多详细信息(如何进行)非常感谢您的帮助
-
顺便说一句,我的项目还没有使用数据库,我只是创建了项目并启动了服务器
-
只需做一个“作曲家删除学说/迁移”,问题就会消失。无论您是否使用数据库,您都会在开发模式下收到此错误。只是其中之一。
-
@Cerad 删除教义/doctrine-migrations-bundle 有效,但是,你能解释一下为什么我需要删除它而不是课程的老师吗?另外,也许我将来会需要它?感谢您的帮助!
标签: postgresql symfony pdo