Menu

Showing posts with label runtime. Show all posts
Showing posts with label runtime. Show all posts

Thursday, August 15, 2019

[Laravel - Config] วิธีการเพิ่มหรือแก้ไขค่าตัวแปรในไฟล์ .env ในขณะ Runtime
[Laravel - Config] How to Add or Modify Variable Value in .env File at Runtime

ไฟล์ .env เป็นไฟล์สำหรับเก็บค่า environment variables ต่างๆของ Application

โดยปกติแล้ว เราสามารถใส่ชื่อตัวแปรและค่าของตัวแปรนั้นๆเข้าไปในไฟล์ .env ได้เลย

แต่ในบางกรณี เราไม่สามารถกำหนดค่าของตัวแปรนั้นได้ เช่น ค่าที่ต้อง encrypt ผ่าน Application หรือค่าของตัวแปรนั้นสามารถหาได้ในขณะ Runtime เท่านั้น เช่น IP address ของ Host server เป็นต้น