Database driver not found in parameters.yml in Symfony 2 - database

i am newbie at Symfony , i just created a new Symfony 2.8 project using this command
$ composer create-project symfony/framework-standard-edition ecommerce "2.8.*"
the project is successfully created but since i have to work with pdo_mysql
in the configuration file parameters.yml i didn't find the " database_driver: pdo_mysql "
the database driver is not mentioned at all ! should i just add it manually in parameters.yml or how can i automatically generate it ?
Notice : PDO_Mysql is already installed and my PHP version is 5.6.31
this my parameters.yml file :
parameters.yml :
# This file is auto-generated during the composer install
parameters:
database_host: 127.0.0.1
database_port: null
database_name: symfony
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: ThisTokenIsNotSoSecretChangeIt

Related

Mongosh connection error: MongoServerSelectionError: Hostname/IP does not match certificate’s altnames

I’m learning MongoDB and set up an Atlas account. I’m trying to connect to my database using mongosh, allowed all IPs, set up my user and password credentials but I’m getting an error:
MongoServerSelectionError: Hostname/IP does not match certificate's altnames: Host: ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net. is not in the cert's altnames: DNS:*.mongodb.net, DNS:mongodb.net
Upon checking my logs, this is what shows:
{"t":{"$date":"2023-02-15T10:21:27.465Z"},"s":"I","c":"MONGOSH","id":1000000000,"ctx":"log","msg":"Starting log","attr":{"execPath":"/opt/homebrew/Cellar/node/19.6.0/bin/node","envInfo":{"EDITOR":null,"NODE_OPTIONS":null,"TERM":"xterm-256color"},"version":"1.7.1","distributionKind":"packaged","buildArch":"x64","buildPlatform":"linux","buildTarget":"unknown","buildTime":"2023-02-13T19:19:00.135Z","gitVersion":"1bf0d7775443ac1849cc2597465d54eca867acea","nodeVersion":"v19.6.0","opensslVersion":"1.1.1s","sharedOpenssl":true}}
{"t":{"$date":"2023-02-15T10:21:27.469Z"},"s":"I","c":"MONGOSH","id":1000000005,"ctx":"config","msg":"User updated"}
{"t":{"$date":"2023-02-15T10:21:27.470Z"},"s":"I","c":"MONGOSH","id":1000000048,"ctx":"config","msg":"Loading global configuration file","attr":{"filename":"/etc/mongosh.conf","found":false}}
{"t":{"$date":"2023-02-15T10:21:27.475Z"},"s":"E","c":"DEVTOOLS-CONNECT","id":1000000041,"ctx":"mongosh-deps","msg":"Missing optional dependency","attr":{"name":"mongodb-client-encryption","error":"Cannot find module 'mongodb-client-encryption'\nRequire stack:\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/node_modules/#mongodb-js/devtools-connect/lib/connect.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/node_modules/#mongodb-js/devtools-connect/lib/index.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/node_modules/#mongosh/service-provider-server/lib/cli-service-provider.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/node_modules/#mongosh/service-provider-server/lib/index.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/lib/cli-repl.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/lib/index.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/lib/run.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/bin/mongosh.js"}}
{"t":{"$date":"2023-02-15T10:21:27.517Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000039,"ctx":"mongosh-connect","msg":"Resolving SRV record succeeded","attr":{"from":"mongodb+srv://<credentials>#cluster0.cbhjwlv.mongodb.net/myFirstDatabase?appName=mongosh+1.7.1","to":"mongodb://<credentials>#ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net,ac-kiiemsq-shard-00-01.cbhjwlv.mongodb.net,ac-kiiemsq-shard-00-02.cbhjwlv.mongodb.net/myFirstDatabase?appName=mongosh+1.7.1&authSource=admin&replicaSet=atlas-142s5d-shard-0&tls=true","resolutionDetails":[{"query":"SRV","hostname":"_mongodb._tcp.cluster0.cbhjwlv.mongodb.net","error":null,"wasNativelyLookedUp":true},{"query":"TXT","hostname":"cluster0.cbhjwlv.mongodb.net","error":null,"wasNativelyLookedUp":true}]}}
{"t":{"$date":"2023-02-15T10:21:27.530Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000042,"ctx":"mongosh-connect","msg":"Initiating connection attempt","attr":{"uri":"mongodb://<credentials>#ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net,ac-kiiemsq-shard-00-01.cbhjwlv.mongodb.net,ac-kiiemsq-shard-00-02.cbhjwlv.mongodb.net/myFirstDatabase?appName=mongosh+1.7.1&authSource=admin&replicaSet=atlas-142s5d-shard-0&tls=true","driver":{"name":"nodejs|mongosh","version":"4.14.0"},"devtoolsConnectVersion":"1.4.4","host":"ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net:27017,ac-kiiemsq-shard-00-01.cbhjwlv.mongodb.net:27017,ac-kiiemsq-shard-00-02.cbhjwlv.mongodb.net:27017"}}
{"t":{"$date":"2023-02-15T10:21:27.867Z"},"s":"W","c":"DEVTOOLS-CONNECT","id":1000000034,"ctx":"mongosh-connect","msg":"Server heartbeat failure","attr":{"connectionId":"ac-kiiemsq-shard-00-02.cbhjwlv.mongodb.net:27017","failure":"","isFailFast":false,"isKnownServer":true}}
{"t":{"$date":"2023-02-15T10:21:28.053Z"},"s":"W","c":"DEVTOOLS-CONNECT","id":1000000034,"ctx":"mongosh-connect","msg":"Server heartbeat failure","attr":{"connectionId":"ac-kiiemsq-shard-00-01.cbhjwlv.mongodb.net:27017","failure":"Hostname/IP does not match certificate's altnames: Host: ac-kiiemsq-shard-00-01.cbhjwlv.mongodb.net. is not in the cert's altnames: DNS:*.mongodb.net, DNS:mongodb.net","isFailFast":false,"isKnownServer":true}}
{"t":{"$date":"2023-02-15T10:21:28.200Z"},"s":"W","c":"DEVTOOLS-CONNECT","id":1000000034,"ctx":"mongosh-connect","msg":"Server heartbeat failure","attr":{"connectionId":"ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net:27017","failure":"Hostname/IP does not match certificate's altnames: Host: ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net. is not in the cert's altnames: DNS:*.mongodb.net, DNS:mongodb.net","isFailFast":false,"isKnownServer":true}}
I’ve tried connecting through Mongodb Compass and the connection is successful. I'm using a Mac with mongoDB and Mongosh installed through brew, all updated to the latest version.
If you downgrade your version of mongosh to 1.6.2, you will be able to connect.
brew uninstall mongodb-community
brew uninstall mongosh
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/4519776bc4563548dcd8c8639ac7e073b107c381/Formula/mongosh.rb
brew install ./mongosh.rb

Unable to launch IEDriverServer - Failed to start server with: port=xxxxx

We are trying to launch an IE browser using the RemoteWebDriver interface.
On the client side, we run the following command to start the selenium-standalone-server.jar
java -Dwebdriver.ie.driver=IEDriverServer.exe -jar selenium-standalone-server.jar
The selenium server starts fine, but there is an error when I try to create a session.
18:52:58. 128 INFO - Launching a standalone Selenium Server
18:52:58.236 INFO - Java: Oracle Corporation 25.251-608
18:52:58.236 INFO - OS: Windows Server 2016 10.amd64 18:52:58.266 INFO - V2.53.1, with core v2.53.1. Built from revision a36b8b1
18:52:58.391 INFO - Driver class not found: com.opera.core.systems. OperaDriver
18:52:58.391 INFO - Driver provider com.opera.core.systems. OperaDriver is not registered
18:52:58.426 INFO - Driver provider org.openda. selenium.safari.SafariDriver registration is skipped: registration capabilities Capabilities [{browserName=safari, version, platform-MAC}] does not match the current platforn XP
18:52:58.429 INFO - Driver class not found: org.openga.selenium.htmlunit.Htm UnitDriver
18:52:58.429 INFO - Driver provider org.openga.selenium.htmlunit.HtmlUnitDriver is not registered
18:52:58.551 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:5555/wd/hub
18:52:58.552 INFO - Selenium Server is up and running 18:53:03.425
INFO - Executing: [new session: Capabilities [{browserName-internet explorer}]]>
18:53:03.448 INFO . Creating a new session for Capabilities [{browserName-internet explorer}]
Failed to start the server with: port - '32956', host = '', log level = '', log file = '', whitelisted ips = ''.
The point to note here is the last line
Failed to start the server with: port - '32956', host = '', log level = '', log file = '', whitelisted ips = ''.
After this, the browser does not launch and throws a TimeoutException.
I tried to manually launch the IEDriverServer using the following command:
.\IEDriverServer.exe /host=127.0.0.1 /log-level=DEBUG
And I got the below output
2022-10-11 18:52:29:611 server.cC(86) Starting WebDriver server on port: *5555' on host: 127.0.0.1
2022-10-11 18:52:29:611 IEServer.cpp(32) Driver version: 2.53.1.2 (32-bit) D
2022-10-11 18:52:29:612 server.cc(148) Civetweb ACL is -e.e.e.e/e,+127.0.0.1 W
2022-10-11 18:52:29:614 server.cc(158) Failed to start Civetweb
Failed to start the server with: port - '32956', host = '', log level = '', log file = '', whitelisted ips = ''.
Since the error said Failed to start Civetweb, I tried googling what that was, but couldn't find out what the issue was.
Please help us out.
Below is our environment:
OS: Windows Server 2016
Selenium Version: 2.53.1
IEDriverServer Version: 2.53.1
IE Version (installed on the machine): Version 1067 (OS Build: 14393.5356)

How can I connect SQL Server with ORM Doctrine on my symfony project?

doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
host: 127.0.0.1
port: 8889
user: '%env(DATABASE_USER)%'
password: '%env(DATABASE_PWD)%'
dbname: '%env(DATABASE_NAME)%'
# With Symfony 3.3, remove the `resolve:` prefix
# url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: yml
dir: '%kernel.project_dir%/config/doctrine'
prefix: 'App\Entity'
alias: App
You need to use driver pdo_sqlsrv or sqlsrv, not pdo_mysql.
(See doctrine configuration documentation).
pdo_sqlsrv: A Microsoft SQL Server driver that uses pdo_sqlsrv PDO
sqlsrv: A Microsoft SQL Server driver that uses the sqlsrv PHP
extension.
Available configuration for pdo_sqlsrv/sqlsrv are:
user (string): Username to use when connecting to the database.
password (string): Password to use when connecting to the database.
host (string): Hostname of the database to connect to.
port (integer): Port of the database to connect to.
dbname (string): Name of the database/schema to connect to.
The documentation says that:
The following drivers support automatic database platform detection
out of the box without any extra configuration required:
pdo_mysql
mysqli
pdo_pgsql
pdo_sqlsrv
sqlsrv
So you dont need to specify server_version.
You would have:
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_sqlsrv'
charset: utf8mb4
host: 127.0.0.1
port: 8889
user: '%env(DATABASE_USER)%'
password: '%env(DATABASE_PWD)%'
dbname: '%env(DATABASE_NAME)%'
# With Symfony 3.3, remove the `resolve:` prefix
# url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: yml
dir: '%kernel.project_dir%/config/doctrine'
prefix: 'App\Entity'
alias: App

How to solve this SQLSTATE[HY000] [2002] no connection could be made because the target machine actively refused it

I am trying to follow an e-commerce tutorial where I have to create the connection with the database. I am on windows 7 with xampp v3.2.
So I use this : php bin/console generate:doctrine:entity
which gives me this error :
SQLSTATE[HY000] [2002] no connection could be made because the target
machine actively refused it
I closed xampp and I still had the same error. So I understand it comes from the configuration; somehow my shell doesn't communicate with my sql server from xampp.
here is my parameters.yml :
# This file is auto-generated during the composer install
parameters:
database_host: localhost
database_port: 3306
database_name: market
database_user: sebastian
database_password:
mailer_transport: smtp
mailer_host: localhost
mailer_user: null
mailer_password: null
secret:
and here my config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "#EcommerceBundle/Resources/config/services.yml" }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
I checked for the extension php_pdo_mysql.dl and it is enabled.
I verified the database name, user and password.
here is a netstat :
netstat
Make sure that your MySQL server is running and that it's using that port (in xampp\mysql\bin\my.ini). Make sure that you're able to connect manually with those credentials as well.
Also, where are you specifying the database driver in your parameters.yml? Normally you should have something like this:
database_driver: pdo_mysql
And lastly, make sure that you don't have a different parameters.yml file included in your config_dev.yml because Symfony commands, by default, use the dev environment.
thank you for your answer.
I have in my.ini 3306 port so it is the good one. I have intalled symfony2.8 and it is working so there is no credentials problems. I also tried to add the line with pdo_mysql but the error message is an pdo_exception, that means pdo works as well.
I also check config.dev but I don't really know what can be wrong inside. So I show you what it looks like :
imports:
- { resource: config.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event]
console:
type: console
channels: [!event, !doctrine]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
#swiftmailer:
# delivery_address: me#example.com
thank for your help
i cant connect to mysql on xamppp
install mysql 8 on my system on port 3307
and its worked great with laravel.
if you want please install mysql workbench (instead of phpmyadmin)

Symfony 2.4 - PDOException]could not find driver: pdo_sqlsrv

For "reasons of fate", I need to build a small program, and to do it quickly, I will with symfony 2.4.
The program in question is connected to a SQLServer data base under a Windows 2008 server. But when trying to connect, I get error driver (with mysql never happened). My parameters.yml is like this (obviously there are important parameters modified)
database_driver: pdo_sqlsrv
database_host: 10.244.xxx.xxx
database_port: null
database_name: imasuperprodatabase
database_user: wololo
database_password: epicpassword
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: secrettokenplz
database_path: null
Any idea?

Resources