Skip to content

Commit

Permalink
Merge pull request #18 from mpdude/config-env-vars
Browse files Browse the repository at this point in the history
Make server URL and secret configurable through env vars
  • Loading branch information
jbouzekri committed Jan 4, 2021
2 parents 5cccddc + 9f890f1 commit b3dec51
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function getConfigTreeBuilder()
->addDefaultsIfNotSet()
->children()
->scalarNode('url')
->defaultValue('http://localhost:8888')
->defaultValue('%env(THUMBOR_URL)%')
->end()
->scalarNode('secret')
->defaultValue('')
->defaultValue('%env(THUMBOR_SECURITY_KEY)%')
->end()
->end()
->end()
Expand Down
2 changes: 2 additions & 0 deletions DependencyInjection/JbPhumborExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function load(array $configs, ContainerBuilder $container)
*/
protected function loadConfiguration(ContainerBuilder $container, array $config)
{
$container->setParameter('env(THUMBOR_URL)', 'http://localhost:8888');
$container->setParameter('env(THUMBOR_SECURITY_KEY)', '');
$container->setParameter('phumbor.server.url', $config['server']['url']);
$container->setParameter('phumbor.secret', $config['server']['secret']);
$container->setParameter('phumbor.transformations', $config['transformations']);
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jb_phumbor:
secret: 123456789
```
Alternatively, you can also set the environment variables `THUMBOR_URL` and `THUMBOR_SECURITY_KEY` for these two settings, for example from your `.env`
file or from inside your webserver configuration.

Quick use case
--------------

Expand Down
4 changes: 2 additions & 2 deletions Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ protected static function getBundleDefaultConfig()
{
return array(
'server' => array(
'url' => 'http://localhost:8888',
'secret' => ''
'url' => '%env(THUMBOR_URL)%',
'secret' => '%env(THUMBOR_SECURITY_KEY)%'
),
'transformations' => array()
);
Expand Down

0 comments on commit b3dec51

Please sign in to comment.