What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hello Everyone, I am trying to access custom development config from file src/config/Shared/config_d
Hello Everyone, I am trying to access custom development config from file src/config/Shared/config_default-development.php but not able to access it through Config::get(). I have tried after bootstraping with deploy.dev.yml and cleared cache as well but nothing works.
Comments
-
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
hi, this config is not loaded if you do not use vagrant setup (or if you touched sth else)
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
Please have a look in vendor/spryker/config/src/Spryker/Shared/Config/Config.php which config gets loaded when
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
environment should be defined by βenvironment: docker.devβ in the deploy.dev.yml
0 -
I am using docker based setup
0 -
Which means config_default-docker.dev.php is the one loaded when using docker based setup instead of config_default-development.php ?
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
yes. if it exists. By default you should put everything in config_default.php
0 -
if we have environment specific credentials like different keys for production and development environment, where should we put that?
0 -
because config_default.php is the default file which will be initialised for all the environments.
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
credentials etc should normally be set via env-variables. Overall a best-practise is to set env-specific config values via environment variables
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
similar to
$config[MailConstants::SMTP_HOST] = getenv('SPRYKER_SMTP_HOST') ?: null;
0 -
Thanks Florian! does it mean we need to have different env-variables for each environment? like
getenv('spryker_dev_SMTP') for dev and for prod getenv('spryker_prod_SMTP')
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
no, same env-variable. the values would be set different by the deploy-script (the one which setup the services in the cloud etc). Are you in the spryker cloud?
0 -
nope. running in local linux based docker installation.
0 -
@florian.scholz deploy-script means jenkins script used in the cloud?
0 -
currently, we are trying to do that in local ubuntu installation with docker. getenv() will pick those variables from? deply.dev.yml? or .env file inside spryker installation dir?
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
yes, for local environment i guess - but you wrote about
if we have environment specific credentials like different keys for production and development environment
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
hmm.. let my try to explain different:
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βοΈ - Guardians (admin)
first rule: you should not store any credentials in code!
imagine you have two new settings:
my-third-party-service-user and my-third-party-passwordyou would set sth like in config_default.php
$config[MyConstants::MY_THIRD_PARTY_SERVICE_USER] = getenv('SPRYKER_MY_THIRD_PARTY_SERVICE_USER') ?: null; $config[MyConstants::MY_THIRD_PARTY_SERVICE_PASSWORD] = getenv('SPRYKER_MY_THIRD_PARTY_SERVICE_PASSWORD') ?: null;
When you deploy to staging or production you can align with the dev-ops team to set the env-variables to the dedicated values while deploying the services.
This is the way to go for deployment but does not help you yet for you local environment.
For local development you have two possibilities:
A (clean way):
create config_local.php (IN ADDITION TO THE PREVIOUS CODE!) and put$config[MyConstants::MY_THIRD_PARTY_SERVICE_USER] = 'my-user'; $config[MyConstants::MY_THIRD_PARTY_SERVICE_PASSWORD] = 'my-password';
B (will be committed, so not good for credentials):
set the default to your credentials rather thennull
in the config_default.php$config[MyConstants::MY_THIRD_PARTY_SERVICE_USER] = getenv('SPRYKER_MY_THIRD_PARTY_SERVICE_USER') ?: 'my-user'; $config[MyConstants::MY_THIRD_PARTY_SERVICE_PASSWORD] = getenv('SPRYKER_MY_THIRD_PARTY_SERVICE_PASSWORD') ?: 'my-password';
0 -
Understood !
0 -
Thanks Florian!
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 930 Developer Corner
- 788 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 33 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random