Use environmental variables for parameters

This commit is contained in:
Kamil Kokot 2018-08-09 14:40:58 +02:00
parent 88598c4036
commit 4f7b1fdadb
No known key found for this signature in database
GPG key ID: 7BD76F7054D93C89
7 changed files with 28 additions and 50 deletions

23
.env.dist Normal file
View file

@ -0,0 +1,23 @@
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
###> symfony/framework-bundle ###
APP_ENV=dev
APP_DEBUG=1
APP_SECRET=EDITME
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_URL=mysql:///root@127.0.0.1/sylius_${APP_ENV}?serverVersion=5.5
###< doctrine/doctrine-bundle ###
###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=smtp://localhost
###< symfony/swiftmailer-bundle ###

View file

@ -1,5 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
imports:
- { resource: "parameters.yml" }

View file

@ -1,31 +0,0 @@
parameters:
database_driver: "%env(SYLIUS_DATABASE_DRIVER)%"
database_host: "%env(SYLIUS_DATABASE_HOST)%"
database_port: "%env(SYLIUS_DATABASE_PORT)%"
database_name: "%env(SYLIUS_DATABASE_NAME)%"
database_user: "%env(SYLIUS_DATABASE_USER)%"
database_password: "%env(SYLIUS_DATABASE_PASSWORD)%"
# You should uncomment this if you want use pdo_sqlite.
# database_path: "%kernel.project_dir%/data.db3"
mailer_transport: "%env(SYLIUS_MAILER_TRANSPORT)%"
mailer_host: "%env(SYLIUS_MAILER_HOST)%"
mailer_user: "%env(SYLIUS_MAILER_USER)%"
mailer_password: "%env(SYLIUS_MAILER_PASSWORD)%"
secret: "%env(SYLIUS_SECRET)%"
# Fallback values (used if environmental variables are not set)
env(SYLIUS_DATABASE_DRIVER): pdo_mysql
env(SYLIUS_DATABASE_HOST): 127.0.0.1
env(SYLIUS_DATABASE_PORT): ~
env(SYLIUS_DATABASE_NAME): sylius
env(SYLIUS_DATABASE_USER): root
env(SYLIUS_DATABASE_PASSWORD): ~
env(SYLIUS_MAILER_TRANSPORT): smtp
env(SYLIUS_MAILER_HOST): 127.0.0.1
env(SYLIUS_MAILER_USER): ~
env(SYLIUS_MAILER_PASSWORD): ~
env(SYLIUS_SECRET): EDITME

View file

@ -1,10 +1,4 @@
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
server_version: "5.5"
url: '%env(resolve:DATABASE_URL)%'
charset: UTF8

View file

@ -1,9 +1,9 @@
framework:
translator: { fallbacks: ["%locale%", "en"] }
secret: "%secret%"
secret: '%env(APP_SECRET)%'
router:
resource: "%kernel.project_dir%/app/config/routing.yml"
strict_requirements: "%kernel.debug%"
strict_requirements: '%kernel.debug%'
form: true
csrf_protection: true
validation: { enable_annotations: true }

View file

@ -2,5 +2,5 @@ liip_imagine:
resolvers:
default:
web_path:
web_root: "%kernel.project_dir%/web"
web_root: "%kernel.project_dir%/public"
cache_prefix: "media/cache"

View file

@ -1,5 +1,2 @@
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
url: '%env(MAILER_URL)%'