[英]Symfony2 cannot connect to sqlite
Im trying to use sqlite base in my behat tests in symfony2. 我试图在symfony2中的behat测试中使用sqlite base。 As far as im am, behat in symfony2 finds my base, and can create fixtures in it.
就我而言,symfony2中的behat找到了我的基础,并且可以在其中创建固定装置。 Problem is my test site cannot connect to this base.
问题是我的测试站点无法连接到此基站。
This is my config_test.yml
: 这是我的
config_test.yml
:
doctrine:
dbal:
driver: pdo_sqlite
host: 127.0.0.1
dbname: "%database_name%_test"
path: tests/eg_test.db
This is my config.yml
: 这是我的
config.yml
:
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
This is my behat.yml
: 这是我的
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
This is log i get back after trying to log into my site. 这是我尝试登录我的网站后回来的日志。 Doesn't matter if user exists or not.
如果用户存在与否则无关紧要。 So its not fault of wrong password or something like that.
所以它不是错误的密码错误或类似的东西。 Seems like site just dont connect to base.
似乎网站只是不连接到基地。
[2017-03-27 10:22:09] request.INFO: Matched route "fos_user_security_check".
[2017-03-27 10:22:09] request.INFO:匹配的路线“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.
{“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 “,”方法“:”POST“} [] [2017-03-27 10:22:10] security.INFO:身份验证请求失败。 {"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.
{“exception”:“[object](Symfony \\ Component \\ Security \\ Core \\ Exception \\ AuthenticationServiceException(code:0):驱动程序中发生异常:SQLSTATE [HY000] [14]无法在/ var / www打开数据库文件/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php:94,Dictrine \\ DBAL \\ Exception \\ ConnectionException(code:0):驱动程序中出现异常:SQLSTATE [HY000] [14]无法在/var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php:82,Doctrine \\ DBAL \\ Driver \\ PDOException(代码:14)中打开数据库文件:SQLSTATE [HY000 ] [14]无法在/var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47打开数据库文件,PDOException(代码:14):SQLSTATE [HY000] [14]无法打开数据库文件/var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)“} [] [2017-03-27 10:22:10] security.DEBUG:身份验证失败,重定向触发。 {"failure_path":"/login"} [] [2017-03-27 10:22:10] request.INFO: Matched route "fos_user_security_login".
{“failure_path”:“/ login”} [] [2017-03-27 10:22:10] request.INFO:匹配路由“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.
{“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 “,”方法“:”GET“} [] [2017-03-27 10:22:10] security.INFO:使用匿名令牌填充TokenStorage。 [] []
[] []
And this is error i get on my site when i try to log in from browser: 当我尝试从浏览器登录时,这是我在我的网站上出现的错误:
Authentication request could not be processed due to a system problem.
由于系统问题,无法处理身份验证请求。
And error when I try to register new user: 当我尝试注册新用户时出错:
An exception occured in driver: SQLSTATE[HY000] [14] unable to open database file
驱动程序中发生异常:SQLSTATE [HY000] [14]无法打开数据库文件
I created my sqlite database as close to standard mysql base im using on prod. 我使用on prod创建了我的sqlite数据库,接近标准的mysql base im。 After it I used
bin/console doctrine:schema:update --force --env=test
. 之后我使用了
bin/console doctrine:schema:update --force --env=test
。 My database got good file mod (-rwxrwxr-x) and is used by right user and group. 我的数据库获得了良好的文件模块(-rwxrwxr-x),并由正确的用户和组使用。
Change your config_test.yml to this: 将config_test.yml更改为:
doctrine:
dbal:
connections:
default:
driver: pdo_sqlite
path: %kernel.cache_dir%/default.db
charset: UTF8
And then grant correct permissions show in here: Setting up or Fixing File Permissions You're going to run commands in either 2nd or 3rd depending on your operating system. 然后在此处授予正确的权限: 设置或修复文件权限您将根据您的操作系统运行第二个或第三个命令。
If you go to your parameters.yml file you should see the path, something like this : database_path: '%kernel.project_dir%/var/data/data.sqlite'
, another advise : create a directory in /var
and put your data.sqlite
file in it 如果你去你的parameters.yml文件,你应该看到这样的路径:
database_path: '%kernel.project_dir%/var/data/data.sqlite'
,另一个建议:在/var
创建一个目录并放入你的data.sqlite
文件
Hope it helps :) 希望能帮助到你 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.