Skip to content

Commit 21fcb92

Browse files
dzuelkejaviereguiluz
authored andcommitted
Use dynamic env params for critical settings and restore Heroku deploys
1 parent 0313e7a commit 21fcb92

File tree

8 files changed

+24
-18
lines changed

8 files changed

+24
-18
lines changed

app.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@
99
"repository": "https://github.com/symfony/symfony-demo",
1010
"logo": "https://symfony.com/images/v5/pictos/demoapp.svg?v=4",
1111
"success_url": "/",
12+
"scripts": {
13+
"postdeploy": "php bin/console doctrine:schema:create && php bin/console doctrine:fixtures:load -n"
14+
},
1215
"env": {
1316
"SYMFONY_ENV": "prod",
17+
"SYMFONY_LOG": "php://stderr",
1418
"SYMFONY_SECRET": {
1519
"description": "Extra entropy for %kernel.secret%; used for CSRF tokens, cookies and signed URLs.",
1620
"generator": "secret"
1721
}
1822
},
23+
"addons": [
24+
"heroku-postgresql"
25+
],
1926
"image": "heroku/php"
2027
}

app/AppKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function registerBundles()
2121
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
2222
new CodeExplorerBundle\CodeExplorerBundle(),
2323
new AppBundle\AppBundle(),
24+
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), // used for initial population of non-SQLite databases in production envs
2425
// uncomment the following line if your application sends emails
2526
// new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
2627
];
@@ -34,7 +35,6 @@ public function registerBundles()
3435
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
3536
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
3637
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
37-
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
3838
}
3939

4040
return $bundles;

app/config/config.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ framework:
3131
# http://symfony.com/doc/current/book/http_cache.html#edge-side-includes
3232
esi: { enabled: true }
3333
translator: { fallback: "%locale%" }
34-
secret: "%secret%"
34+
secret: "%env(SYMFONY_SECRET)%"
3535
router:
3636
resource: "%kernel.root_dir%/config/routing.yml"
3737
strict_requirements: ~
@@ -61,10 +61,10 @@ twig:
6161
# Doctrine Configuration (used to access databases and manipulate their information)
6262
doctrine:
6363
dbal:
64-
# if you don't want to use SQLite, comment the two following lines
65-
driver: "pdo_sqlite"
66-
path: "%kernel.root_dir%/data/blog.sqlite"
67-
# uncomment the following lines to use a database different than SQLite
64+
# if you don't want to use SQLite, change the URL in parameters.yml or set the DATABASE_URL environment variable
65+
url: "%env(DATABASE_URL)%"
66+
67+
# instead of using a URL, you may also uncomment the following lines to configure your database
6868
# driver: pdo_mysql
6969
# host: "%database_host%"
7070
# port: "%database_port%"

app/config/config_dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ monolog:
1515
handlers:
1616
main:
1717
type: stream
18-
path: "%kernel.logs_dir%/%kernel.environment%.log"
18+
path: "%env(SYMFONY_LOG)%"
1919
level: info
2020
console:
2121
type: console

app/config/config_prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ monolog:
1919
handler: nested
2020
nested:
2121
type: stream
22-
path: "%kernel.logs_dir%/%kernel.environment%.log"
22+
path: "%env(SYMFONY_LOG)%"
2323
level: debug
2424
console:
2525
type: console

app/config/parameters.yml.dist

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ parameters:
66
# this demo application uses an embedded SQLite database to simplify setup.
77
# in a real Symfony application you probably will use a MySQL or PostgreSQL database
88
# the path must be relative or else it will not work on Windows
9-
database_url: 'sqlite:///%kernel.root_dir%/data/blog.sqlite'
9+
env(DATABASE_URL): 'sqlite:///%kernel.root_dir%/data/blog.sqlite'
1010

1111
# Uncomment this line to use a MySQL database instead of SQLite:
1212
#
13-
# database_url: 'mysql://root:[email protected]:3306/symfony_demo'
13+
# env(DATABASE_URL): 'mysql://root:[email protected]:3306/symfony_demo'
1414
#
1515
# Furthermore, you must remove or comment out the "doctrine" section from config_dev.yml regarding SQLite!
1616
#
@@ -35,4 +35,7 @@ parameters:
3535
# used internally by Symfony in several places (CSRF tokens, URI signing,
3636
# 'Remember Me' functionality, etc.)
3737
# see: http://symfony.com/doc/current/reference/configuration/framework.html#secret
38-
secret: 'secret_value_for_symfony_demo_application'
38+
env(SYMFONY_SECRET): 'secret_value_for_symfony_demo_application'
39+
40+
# Destination for log files; can also be "php://stderr" etc
41+
env(SYMFONY_LOG): %kernel.logs_dir%/%kernel.environment%.log

composer.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@
6464
"symfony-tests-dir": "tests",
6565
"symfony-assets-install": "relative",
6666
"incenteev-parameters": {
67-
"file": "app/config/parameters.yml",
68-
"env-map": {
69-
"database_url": "DATABASE_URL",
70-
"secret": "SYMFONY_SECRET"
71-
}
67+
"file": "app/config/parameters.yml"
7268
}
7369
}
7470
}

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)