Symfony2 无法连接到 sqlite
Symfony2 cannot connect to sqlite
我正在尝试在 symfony2 的 behat 测试中使用 sqlite base。就我而言,symfony2 中的 behat 找到了我的基础,并且可以在其中创建固定装置。问题是我的测试站点无法连接到这个基地。
这是我的 config_test.yml
:
doctrine:
dbal:
driver: pdo_sqlite
host: 127.0.0.1
dbname: "%database_name%_test"
path: tests/eg_test.db
这是我的 config.yml
:
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
这是我的 behat.yml
:
default:
suites:
default:
paths:
features: '%paths.base%/features'
bootstrap: '%paths.base%/features/bootstrap'
contexts:
- FeatureContext: ~
- EwidencjaContext:
userManager: '@fos_user.user_manager'
em: '@doctrine.orm.entity_manager'
packageManager: '@em.package_manager'
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
base_url: http://nginx/app_test.php
goutte: ~
selenium2:
browser: "chrome"
wd_host: http://selenium_chrome:4444/wd/hub
capabilities: { "browserName": "chrome", "browser": "chrome"}
Bex\Behat\ScreenshotExtension:
image_drivers:
local:
screenshot_directory: tests/features/images/
clear_screenshot_directory: true
这是我尝试登录我的网站后返回的日志。用户是否存在无关紧要。所以这不是密码错误或类似问题的错。似乎网站只是没有连接到基地。
[2017-03-27 10:22:09] request.INFO: Matched route "fos_user_security_check". {"route":"fos_user_security_check","route_parameters":{"_controller":"FOS\UserBundle\Controller\SecurityController::checkAction","_route":"fos_user_security_check"},"request_uri":"http://localhost/app_test.php/login_check","method":"POST"} []
[2017-03-27 10:22:10] security.INFO: Authentication request failed. {"exception":"[object] (Symfony\Component\Security\Core\Exception\AuthenticationServiceException(code: 0): An exception occured in driver: SQLSTATE[HY000] [14] unable to open database file at /var/www/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php:94, Doctrine\DBAL\Exception\ConnectionException(code: 0): An exception occured in driver: SQLSTATE[HY000] [14] unable to open database file at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php:82, Doctrine\DBAL\Driver\PDOException(code: 14): SQLSTATE[HY000] [14] unable to open database file at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 14): SQLSTATE[HY000] [14] unable to open database file at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} []
[2017-03-27 10:22:10] security.DEBUG: Authentication failure, redirect triggered. {"failure_path":"/login"} []
[2017-03-27 10:22:10] request.INFO: Matched route "fos_user_security_login". {"route":"fos_user_security_login","route_parameters":{"_controller":"FOS\UserBundle\Controller\SecurityController::loginAction","_route":"fos_user_security_login"},"request_uri":"http://localhost/app_test.php/login","method":"GET"} []
[2017-03-27 10:22:10] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
这是我尝试从浏览器登录时在网站上遇到的错误:
Authentication request could not be processed due to a system problem.
当我尝试注册新用户时出错:
An exception occured in driver: SQLSTATE[HY000] [14] unable to open database file
我创建的 sqlite 数据库接近于标准 mysql base im 在产品上使用。之后我使用了 bin/console doctrine:schema:update --force --env=test
。我的数据库得到了好的文件 mod (-rwxrwxr-x) 并且被正确的用户和组使用。
将您的 config_test.yml 更改为:
doctrine:
dbal:
connections:
default:
driver: pdo_sqlite
path: %kernel.cache_dir%/default.db
charset: UTF8
然后授予正确的权限显示在此处:Setting up or Fixing File Permissions根据您的操作系统,您将 运行 在第二个或第三个中执行命令。
如果你去你的 parameters.yml 文件你应该看到路径,像这样:database_path: '%kernel.project_dir%/var/data/data.sqlite'
,另一个建议:在 /var
中创建一个目录并把你的 data.sqlite
里面的文件
希望对您有所帮助:)
我正在尝试在 symfony2 的 behat 测试中使用 sqlite base。就我而言,symfony2 中的 behat 找到了我的基础,并且可以在其中创建固定装置。问题是我的测试站点无法连接到这个基地。
这是我的 config_test.yml
:
doctrine:
dbal:
driver: pdo_sqlite
host: 127.0.0.1
dbname: "%database_name%_test"
path: tests/eg_test.db
这是我的 config.yml
:
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
这是我的 behat.yml
:
default:
suites:
default:
paths:
features: '%paths.base%/features'
bootstrap: '%paths.base%/features/bootstrap'
contexts:
- FeatureContext: ~
- EwidencjaContext:
userManager: '@fos_user.user_manager'
em: '@doctrine.orm.entity_manager'
packageManager: '@em.package_manager'
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
base_url: http://nginx/app_test.php
goutte: ~
selenium2:
browser: "chrome"
wd_host: http://selenium_chrome:4444/wd/hub
capabilities: { "browserName": "chrome", "browser": "chrome"}
Bex\Behat\ScreenshotExtension:
image_drivers:
local:
screenshot_directory: tests/features/images/
clear_screenshot_directory: true
这是我尝试登录我的网站后返回的日志。用户是否存在无关紧要。所以这不是密码错误或类似问题的错。似乎网站只是没有连接到基地。
[2017-03-27 10:22:09] request.INFO: Matched route "fos_user_security_check". {"route":"fos_user_security_check","route_parameters":{"_controller":"FOS\UserBundle\Controller\SecurityController::checkAction","_route":"fos_user_security_check"},"request_uri":"http://localhost/app_test.php/login_check","method":"POST"} [] [2017-03-27 10:22:10] security.INFO: Authentication request failed. {"exception":"[object] (Symfony\Component\Security\Core\Exception\AuthenticationServiceException(code: 0): An exception occured in driver: SQLSTATE[HY000] [14] unable to open database file at /var/www/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php:94, Doctrine\DBAL\Exception\ConnectionException(code: 0): An exception occured in driver: SQLSTATE[HY000] [14] unable to open database file at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php:82, Doctrine\DBAL\Driver\PDOException(code: 14): SQLSTATE[HY000] [14] unable to open database file at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 14): SQLSTATE[HY000] [14] unable to open database file at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} [] [2017-03-27 10:22:10] security.DEBUG: Authentication failure, redirect triggered. {"failure_path":"/login"} [] [2017-03-27 10:22:10] request.INFO: Matched route "fos_user_security_login". {"route":"fos_user_security_login","route_parameters":{"_controller":"FOS\UserBundle\Controller\SecurityController::loginAction","_route":"fos_user_security_login"},"request_uri":"http://localhost/app_test.php/login","method":"GET"} [] [2017-03-27 10:22:10] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
这是我尝试从浏览器登录时在网站上遇到的错误:
Authentication request could not be processed due to a system problem.
当我尝试注册新用户时出错:
An exception occured in driver: SQLSTATE[HY000] [14] unable to open database file
我创建的 sqlite 数据库接近于标准 mysql base im 在产品上使用。之后我使用了 bin/console doctrine:schema:update --force --env=test
。我的数据库得到了好的文件 mod (-rwxrwxr-x) 并且被正确的用户和组使用。
将您的 config_test.yml 更改为:
doctrine:
dbal:
connections:
default:
driver: pdo_sqlite
path: %kernel.cache_dir%/default.db
charset: UTF8
然后授予正确的权限显示在此处:Setting up or Fixing File Permissions根据您的操作系统,您将 运行 在第二个或第三个中执行命令。
如果你去你的 parameters.yml 文件你应该看到路径,像这样:database_path: '%kernel.project_dir%/var/data/data.sqlite'
,另一个建议:在 /var
中创建一个目录并把你的 data.sqlite
里面的文件
希望对您有所帮助:)