Cant acces to MAMP after creating Database with Doctrine and Symfony2 - doctrine

I'm trying to get on with the Symblog Tutorial for Symfony2 (http://tutorial.symblog.co.uk/docs/doctrine-2-the-blog-model.html)
After I created my databse with php app/console doctrine:database:create I dont have acces to localhost/MAMP/ anymore?! This is the Error Message "Error: Could not connect to MySQL server!"
Can anyone help me?
Thats my config.yml
Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
unix_socket: /var/mysql/mysql.sock
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
Thats my parameters.ini
[parameters]
database_driver="pdo_mysql"
database_host="localhost"
database_port="3306"
database_name="symfony"
database_user="root"
database_password=""

The default port for MAMP server should be 8889 while you are using 3306, the error could be that.
My parameters
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: '8889'
database_name: symfony_blog
database_user: root
database_password: root
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: 7f03537e81f981683bc773b9ec7113ab5861adec
database_path: null

Related

Invalid helo name Jhipster

I have set the file application-prod.yml with mail account but it is not working with mail server , it returns error 550 invalid helo name. i want to know where i can set host correctly.
thanks
mail:
host: mail.xxxx.cloud
port: 587
username: register#xxxx.cloud
password: xxxxxxxxxx
protocol: smtp
tls: true
properties.mail.smtp:
auth: true
starttls.enable: true
ssl.trust: mail.xxxx.cloud
...
...
...
mail:
from: register#xxxx.cloud
base-url: https://host.xxxx.cloud/

Symfony connect to oracle oci8

I'm on Symfony and I can't connect to a Oracle database, but I don't know why. Maybe you can help me a little.
Here my doctrine.yaml
doctrine:
dbal:
default_connection: default
connections:
default:
# configure these for your database server
url: '%env(DATABASE_URL)%'
server_version: '5.7'
charset: utf8mb4
test:
# configure these for your database server
url: '%env(DATABASE_TEST_URL)%'
driver: 'oci8'
server_version: ~
charset: utf8mb4
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
test:
connection: test
mappings:
test:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Test'
prefix: 'App\Entity\Test'
alias: Test
My .env file with 2 database:
DATABASE_URL=mysql://xxx:xxx#mysql:3306/pivot
DATABASE_TEST_URL=//user:owd#host:port/dbname
And here my controller
public function xxx() {
$entityManager = $this->getDoctrine()->getConnection('test');
$sql = 'SELECT * FROM xxx.O2_ADRESSE WHERE ROWNUM = 1';
$stmt = $entityManager->prepare($sql);
$stmt->execute();
dump($stmt->fetchAll());
}
I get the following error :
An exception occurred in driver: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor
Any help on what im doing wrong?
Are you sure that the db is running?
You can check it via sqlplus, eg:
sqlplus user:password#mysql:3306/pivot
Can you update DATABASE_URL and try?
to use oracle: DATABASE_URL="oci8://db_user:db_password#127.0.0.1:1521/db_name"
https://symfony.com/doc/current/doctrine.html
https://symfony.com/doc/current/bundles/DoctrineBundle/configuration.html#oracle-db

elasticsearch.yml ses email config

Took the config from elastic search documentation, and added it to elastic cloud yml.
xpack.notification.email.account:
ses_account:
smtp:
auth: true
starttls.enable: true
starttls.required: true
host: email-smtp.us-east-1.amazonaws.com
port: 587
user: <username>
password: <password>
giving me the below error:
'xpack.notification.email.account.ses_account.profile': is not allowed

Symfony: Doctrine - checking there's a connection

Is there a simple way to debug why Doctrine is not connecting to MySQL?
config.yml has:
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
and parameters.yml seems to have the correct connection information in it. E.g.
parameters:
database_host: 127.0.0.1
database_port: null
database_name: <my database name>
database_user: <my database user>
database_password: <my database password>
However this piece of code still echoes out "Not connected".
$cnx = $this->getDoctrine()->getConnection();
if ($cnx->isConnected()){
echo "Connected";
}
else {
echo "Not connected";
}
and I'm not getting any errors returned.
Any suggestions?
This works:
$em = $this->getDoctrine()->getManager();
$em->getConnection()->connect();
$connected = $em->getConnection()->isConnected();
$connected will be true to indicate it is connected.
The connect() establishes the connection, and then isConnected() returns a boolean to tell if it is connected.

Email service in Jhipster

I'm new to Jhispter and I created an application using the yeoman generator for Jhipster.
When I logged as an admin to this application to check the Health checks section I noticed that email service is down and the details says this :
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: localhost, 25; timeout -1
How can I solve this problem ?
You must fill properties in application-dev.yml or application-prod.yml with your real account data (eg gmail account)
mail:
host: localhost
port: 25
username:
password:
Sample file:
https://github.com/jhipster/jhipster-sample-app-token/blob/master/src/main/resources/config/application-dev.yml
Go to application-prod.yml and add config below to fix it.
spring:
mail:
host: smtp.gmail.com
port: 587
user: your gmail address
password: your password
protocol: smtp
tls: true
auth: true
from: spoonatte#gmail.com
properties.mail.smtp:
auth: true
starttls.enable: true
ssl.trust: smtp.gmail.com
OR in application-prod.yml
mail:
host: smtp.gmail.com
port: 587
username: your gmail address
password: your password
protocol: smtp
tls: true
properties.mail.smtp:
auth: true
starttls.enable: true
ssl.trust: smtp.gmail.com
messages:
cache-seconds: 1
thymeleaf:
cache: false

Resources