尤川豪   ·  4月前
376 貼文  ·  240 留言

關於製作一個 php-dotenv-safe 套件的想法

  • php-dotenv-safe

  • inspired from https://github.com/rolodato/dotenv-safe

  • if the env variable is required, define it in the .env.example

  • you can give it default value in the .env.example

  • or just give it default value in env as the second parameter

  • for team work,

    • if the env value is same for the all team, all environments
    • put it as the env second parameter. and it's almost equal to hard-coded
    • it's in the config file only for SoC purpose
    • maybe, hard-coded is better. don't use env function either
    • if the env value will differ
    • put it in the .env.example to force everyone set it up
  • for personal project

    • might be convenient to put dev values in the .env.example
    • with php-dotenv-safe, no need to use env second parameter at all
  • in laravel, where to put default value? env 2nd param or in .env.example?

  • so it actually breaks single source of truth.

  • with php-dotenv-safe, the default value is always guaranteed.

  • so don't use second parameter at all.

  • force developers to set VAR=null in the .env file.

  • so they know they might just disable some features.

  分享   共 253 次點閱
共有 0 則留言
還沒有人留言。歡迎分享您的觀點、或是疑問。
您的留言
尤川豪
376 貼文  ·  240 留言

Devs.tw 是讓工程師寫筆記、網誌的平台。隨手紀錄、寫作,方便日後搜尋!

歡迎您一起加入寫作與分享的行列!

查看所有文章