i would like to use external parameters to config my parameters.yml.
so i follow this tutorial :
http://symfony.com/doc/current/cookbook/configuration/external_parameters.html
in my parameters.yml i have put this :
parameters:
database_host: localhost
database_port: null
database_name: '%database.name%'
database_user: '%database.user%'
database_password: '%database.pass%'
mailer_transport: smtp
mailer_host: localhost
mailer_user: null
mailer_password: null
secret: ThisTokenIsNotSoSecretChangeIt
it works when i run my website with this parameters except when i clear the cache with command line.
i got this error :
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "database.name". Did you mean this: "database_name"?
Do you know the solution to resolve this problem.
thank you for your help
First create a php file and the logica, then import the php file to the config.yml and after comment the variables in parameters file. Have you tried to do something like this?
# parameters.php
$container->setParameter('database_name', $databaseName);
# app/config/config.yml
imports:
- { resource: parameters.php }
# app/config/parameters.yml
#database_name: '%database.name%'
#database_user: '%database.user%'
Related
I´m trying to import a big sql file for a Wordpress project that we should be really simple.
I would like to use BigDump because PhpMyAdmin make a 413 error.
BigDump does not connect with the server.
I got this error :
Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: H�te inconnu.
Database connection failed due to php_network_getaddresses: getaddrinfo failed: H�te inconnu
I report data from wp-config.php into bigdump.php like this :
$db_server <=> DB_HOST
$db_name <=> DB_NAME
$db_username <=> DB_USER
$db_password <=> DB_PASSWORD
Notice : DB_HOST is neither localhost nor 127.0.0.1
This is the php code which run this part :
$mysqli = new mysqli($db_server, $db_username, $db_password, $db_name);
if (mysqli_connect_error())
{ echo ("<p class=\"error\">Database connection failed due to ".mysqli_connect_error()."</p>\n");
echo ("<p>Edit the database settings in BigDump configuration, or contact your database provider.</p>\n");
$error=true;
}
It´s so weird,..should I input other thing in $db_server ?
Someone one could help me ?
I've got webserver template in CloudFormation. I want to use the same template for http and https.
Idea is that I'll use condition like:
Codition:
Https:
Fn::Equals: [Ref: 05HttpsUsed, Used]
and later I've got section files:
files:
full_path_apache/my_no_ssl.conf:
content: !Sub |
<proper_apache_config>
No SSL config... not important now
</proper_apache_config>
full_path_apache/my_ssl.conf:
content: !Sub |
<proper_apache_config>
SSL config... not important now
</proper_apache_config>
I'm trying to combine this. So depends if I choose to use or not https it will create a correct apache config file.
All this is inside Instace, Metadata, AWS::CloudFormation::Init: and configSets:
Edit:
I've tried also applied solution I used for Security Group:
!If [Https,
{CidrIp: 0.0.0.0/0,
IpProtocol: tcp,
FromPort: '443',
ToPort: '443'}, !Ref "AWS::NoValue"]
But still can't figure it out... Either rollback (timeout) or syntax...
You basically need Fn::If. Something like:
files:
full_path_apache/my.conf:
content: !If
- Https
- !Sub |
<proper_apache_config>
SSL config... not important now
</proper_apache_config>
- !Sub: |
<proper_apache_config>
No SSL config... not important now
</proper_apache_config>
I also think that it might be easier to create two AWS::CloudFormation::Init resources (one for HTTPS, one for non-HTTPS) instead.
I want to prepare my application to be compatible with many databases types. To try it i've used H2, MySql and Postgresql. So 'ive added into build.sbt :
"mysql" % "mysql-connector-java" % "5.1.35",
"org.postgresql" % "postgresql" % "9.4-1201-jdbc41"
and i've added conf/prod.conf with all configuration without database configuration, and 3 files:
conf/h2.conf
include "prod.conf"
db.h2.driver=org.h2.Driver
db.h2.url="jdbc:h2:mem:dontforget"
db.h2.jndiName=DefaultDS
ebean.h2="fr.chklang.dontforget.business.*"
conf/mysql.conf
include "prod.conf"
db.mysql.driver=com.mysql.jdbc.Driver
db.mysql.jndiName=DefaultDS
ebean.mysql="fr.chklang.dontforget.business.*"
conf/postgresql.conf
include "prod.conf"
db.postgresql.driver=org.postgresql.Driver
db.postgresql.jndiName=DefaultDS
ebean.postgresql="fr.chklang.dontforget.business.*"
Add to it i've three folders into conf/evolutions with
evolutions/h2
evolutions/mysql
evolutions/postgresql
with these things user can start my application with this command :
-Dconfig.file=dontforget-conf.conf -DapplyEvolutions.default=true -Dhttp.port=10180 &
And this conf file is
include "postgresql.conf"
db.postgresql.url="jdbc:postgresql:dontforget"
db.postgresql.user=myUserName
db.postgresql.password=myPassword
But with this configuration, when my application try to connect to DB :
The default EbeanServer has not been defined? This is normally set via the ebean.datasource.default property. Otherwise it should be registered programatically via registerServer()]]
So i've tried to add, into my configuration :
ebean.datasource.default=postgresql
but when i add it i've :
Configuration error: Configuration error[Configuration error[]]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94)
at play.api.Configuration.reportError(Configuration.scala:743)
at play.Configuration.reportError(Configuration.java:310)
at play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:56)
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
at scala.collection.immutable.List.foreach(List.scala:383)
at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:91)
at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.api.Play$.start(Play.scala:90)
at play.core.StaticApplication.<init>(ApplicationProvider.scala:55)
at play.core.server.NettyServer$.createServer(NettyServer.scala:253)
at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:289)
at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:284)
at scala.Option.map(Option.scala:145)
at play.core.server.NettyServer$.main(NettyServer.scala:284)
at play.core.server.NettyServer.main(NettyServer.scala)
Caused by: Configuration error: Configuration error[]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94)
at play.api.Configuration.reportError(Configuration.scala:743)
at play.api.db.BoneCPApi.play$api$db$BoneCPApi$$error(DB.scala:271)
at play.api.db.BoneCPApi$$anonfun$getDataSource$3.apply(DB.scala:438)
at play.api.db.BoneCPApi$$anonfun$getDataSource$3.apply(DB.scala:438)
at scala.Option.getOrElse(Option.scala:120)
at play.api.db.BoneCPApi.getDataSource(DB.scala:438)
at play.api.db.DB$$anonfun$getDataSource$1.apply(DB.scala:142)
at play.api.db.DB$$anonfun$getDataSource$1.apply(DB.scala:142)
at scala.Option.map(Option.scala:145)
at play.api.db.DB$.getDataSource(DB.scala:142)
at play.api.db.DB.getDataSource(DB.scala)
at play.db.DB.getDataSource(DB.java:25)
at play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:54)
So i don't understand how i can do it.
YES!!! I've found it! After debug mode (etc...)
There was 2 problems.
First problem : I must add a key into my application.conf :
ebeanconfig.datasource
For me (for exemple), postgresql.conf is modified to :
db.postgresql.driver=org.postgresql.Driver
db.postgresql.jndiName=DefaultDS
ebean.postgresql="fr.chklang.dontforget.business.*"
ebeanconfig.datasource.default=postgresql
Second problem : include into play 2.3.x don't works because conf folder isn't added into classpath (ref Load file from '/conf' directory on Cloudbees ) so we must concat prod.conf, postgresql.conf and dontforget.conf into an only single file.
I hope i have helped any other developper...
Here is what I want to do. I've got some yml file like...
My custom yml file :
# app/config/sv_parameters.yml
parameters:
sv_email:
debug: "debug#debug.com"
admin: "admin#admin.com"
...
The config.yml file, importing my custom params :
# app/config/config.yml
imports:
- { resource: sv_parameters.yml }
...
The config_dev.yml, importing the config.yml, and using a sub-parameter of my custom yml file :
# app/config/config_dev.yml
imports:
- { resource: config.yml }
swiftmailer:
delivery_address: "%sv_email.debug%"
But, when I clear:cache :
You have requested a non-existent parameter "sv_email.debug".
I know in PHP multi-level parameters are arrays. But does that mean we can access them in pure YML ?
I could write my sv_email parameters inline, but that's not as clean as multi levels..
This is not possible to achieve in YML.
You have to move this nested variable to the upper level and then - include it in both needed places.
I have a function in my views.py that print a string. I have run the local server by django.
I wrote this code.The page of this project must show word "hello world" , but it doesn't!
Will you help me fix it?
from django.conf.urls.defaults import *
from mysite.views import hello
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
('^hello/$', hello),
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# url(r'^admin/', include(admin.site.urls)),
)
Judging by what you have and receiving 404 not found I presume you are just going to localhost:8000
However your url setup says that you should go to localhost:8000/hello/ (you have no page set for the index pattern url(r'^$', hello) )
You also need to follow the correct syntax in your URLs. You currently have:
('^hello/$', hello),
You need to have:
url(r'^hello/$', hello),
You can also enable more verbose debugging by going to your settings.py file and setting DEBUG = True