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. I have a question about configuration. Is it a bad practice to use config values from other m

U0134CBTUKS
U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet

Hello. I have a question about configuration. Is it a bad practice to use config values from other modules *Config.php?
Should we provide config values through facade methods to use them from different module?

Comments

  • Ievgen Varava
    Ievgen Varava Sprykee Posts: 154 πŸ§‘πŸ»β€πŸš€ - Cadet

    I would say, it's ok to have direct references at project level

  • Ievgen Varava
    Ievgen Varava Sprykee Posts: 154 πŸ§‘πŸ»β€πŸš€ - Cadet

    this should be taken into account as a part to check on future updates though. You can expect compatibility on facade methods level, but not for underlying code which could be modified even in minor releases

  • UKHD8KTMF
    UKHD8KTMF Posts: 393 πŸ§‘πŸ»β€πŸš€ - Cadet

    returning config values through facade is an overkill. Usual flow is that you define a config in both modules and wire them up together in config.php. We have this all over spryker i.e.

    $config[ApplicationConstants::ZED_TRUSTED_HOSTS]
        = $config[HttpConstants::ZED_TRUSTED_HOSTS]
        = [];
    
  • U0134CBTUKS
    U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet

    Thank you very much for clearing that up! πŸ™‚

  • U0134CBTUKS
    U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet

    @UKHD8KTMF won't config.php get bloted in this case and we'll need to create separate configs?
    maybe it's better then to use it directly how @ULSLLNL7K told πŸ™‚

  • UKHD8KTMF
    UKHD8KTMF Posts: 393 πŸ§‘πŸ»β€πŸš€ - Cadet

    Well, you asked about the good practice. Maybe the better question is if your modules are really independent if they are sharing a config? Maybe the caller should send a transfer (business object) with all needed data. I would not refer to other module configuration. This makes them tightly coupled.

  • U0134CBTUKS
    U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet

    Good tip, I'll have to re-evaluate that they are really independent.

  • U0134CBTUKS
    U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited May 2020

    Looks like spryker does not have standards here also

    /**
     * @see \Spryker\Shared\Price\PriceConfig::PRICE_MODE_NET
     */
    public const PRICE_NET_MODE = 'NET_MODE';
    

    in this case the constant is redefined everywhere which I don't think is a good idea, alhough maybe constants like this are not likely to change πŸ€·β€β™‚οΈ