ich einige enviromental Variablen gesetzt haben beide auf vHost:Symfony 3.0-Konsole erkennen die enviromental Variablen
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog /home/pcmagas/Kwdikas/web/apps/logs/error.log
CustomLog /home/pcmagas/Kwdikas/web/apps/logs/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
Alias /symphotest /home/pcmagas/Kwdikas/web/apps/symphotest/web
<Directory /home/pcmagas/Kwdikas/web/apps/symphotest/web>
AllowOverride All
Require all granted
DirectoryIndex appp_dev.php
</Directory>
<Directory /home/pcmagas/Kwdikas/web/apps/symphotest>
SetEnv OPENSHIFT_POSTGRESQL_DB_HOST localhost
SetEnv OPENSHIFT_POSTGRESQL_DB_PORT 5432
SetEnv OPENSHIFT_APP_NAME sampledb
SetEnv OPENSHIFT_POSTGRESQL_DB_USERNAME sampleuser
SetEnv OPENSHIFT_POSTGRESQL_DB_PASSWORD samplepasswd
</Directory>
</VirtualHost>
auch beide ich als enviromental Variablen an die Shell exportiert:
[email protected]0:~/Kwdikas/web/apps/symphotest$ export | grep OPENSHIFT
declare -x OPENSHIFT_APP_NAME="sampledb"
declare -x OPENSHIFT_POSTGRESQL_DB_HOST="localhost"
declare -x OPENSHIFT_POSTGRESQL_DB_PASSWORD="samplepasswd"
declare -x OPENSHIFT_POSTGRESQL_DB_PORT="5432"
declare -x OPENSHIFT_POSTGRESQL_DB_USERNAME="sampleuser"
Und ich konfigurieren, dass die db Verbindung über benutzerdefinierte - gemacht enviromental Variablen: config.yml:
imports:
- { resource: params.php }
- { resource: security.yml }
- { resource: 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']
#assets_version: SomeVersionScheme
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%/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
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%"
encryption: "%mailer_encryption_method%"
port: "%mailer_port%"
spool: { type: memory }
<?php
$container->setParameter('secret','himitsu');
// Db Parameters
$container->setParameter('database_driver','pdo_pgsql');
$container->setParameter('database_host', getenv("OPENSHIFT_POSTGRESQL_DB_HOST"));
$container->setParameter('database_port', getenv("OPENSHIFT_POSTGRESQL_DB_PORT"));
$container->setParameter('database_name', getenv("OPENSHIFT_APP_NAME"));
$container->setParameter('database_user', getenv("OPENSHIFT_POSTGRESQL_DB_USERNAME"));
$container->setParameter('database_password', getenv("OPENSHIFT_POSTGRESQL_DB_PASSWORD"));
// Ich habe einige zusätzliche Parameter gesetzt, aber jetzt nicht >
Und egal, wenn ich schreibe:
php ./bin/console doctrine:schema:create
bekomme ich folgende Fehlermeldung:
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[08006] [7] FATAL: database "user=''" does not exist
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[08006] [7] FATAL: database "user=''" does not exist
[PDOException]
SQLSTATE[08006] [7] FATAL: database "user=''" does not exist
doctrine:schema:create [--dump-sql] [--em [EM]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
Haben Sie Art der Idee, wie man die Konsole verwaltet, um die Umgebungsvariablen zu lesen?
Das OP hat das Kennwort für den Datenbankbenutzer festgelegt. Siehe die Antwort unten. –