[{"data":1,"prerenderedAt":643},["ShallowReactive",2],{"helpers-navigation":3,"mdc-o8y00b-key":32,"helpers-version":74,"\u002Fdocs\u002Fhelpers\u002Fenvironment-variables":75,"\u002Fdocs\u002Fhelpers\u002Fenvironment-variables-surround":640},[4],{"title":5,"path":6,"stem":7,"children":8,"icon":31},"Helpers","\u002Fdocs\u002Fhelpers","1.docs\u002F8.helpers\u002F1.index",[9,11,15,19,23,27],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Environment Variables","\u002Fdocs\u002Fhelpers\u002Fenvironment-variables","1.docs\u002F8.helpers\u002F2.environment-variables",{"title":16,"path":17,"stem":18},"Meta Tags","\u002Fdocs\u002Fhelpers\u002Fmeta-tags","1.docs\u002F8.helpers\u002F3.meta-tags",{"title":20,"path":21,"stem":22},"Sitemap and robots.txt","\u002Fdocs\u002Fhelpers\u002Fsitemap","1.docs\u002F8.helpers\u002F4.sitemap",{"title":24,"path":25,"stem":26},"Redirects","\u002Fdocs\u002Fhelpers\u002Fredirects","1.docs\u002F8.helpers\u002F5.redirects",{"title":28,"path":29,"stem":30},"Vite","\u002Fdocs\u002Fhelpers\u002Fvite","1.docs\u002F8.helpers\u002F6.vite","i-ri-tools-line",{"data":33,"body":34},{},{"type":35,"children":36},"root",[37],{"type":38,"tag":39,"props":40,"children":41},"element","p",{},[42,45,54,56,63,65,72],{"type":43,"value":44},"text","Kirby Tools is built on ",{"type":38,"tag":46,"props":47,"children":51},"a",{"href":48,"rel":49},"https:\u002F\u002Fgetkirby.com",[50],"nofollow",[52],{"type":43,"value":53},"Kirby",{"type":43,"value":55}," – with gratitude to the team and community who make it. Help me improve the plugins: share feedback in ",{"type":38,"tag":46,"props":57,"children":60},{"href":58,"rel":59},"https:\u002F\u002Fgithub.com\u002Fkirby-tools\u002Fcommunity\u002Fdiscussions",[50],[61],{"type":43,"value":62},"Discussions",{"type":43,"value":64}," or report bugs via ",{"type":38,"tag":46,"props":66,"children":69},{"href":67,"rel":68},"https:\u002F\u002Fgithub.com\u002Fkirby-tools\u002Fcommunity\u002Fissues",[50],[70],{"type":43,"value":71},"Issues",{"type":43,"value":73},".",null,{"id":76,"title":12,"body":77,"description":635,"extension":636,"meta":637,"navigation":180,"path":13,"seo":638,"stem":14,"__hash__":639},"docs\u002F1.docs\u002F8.helpers\u002F2.environment-variables.md",{"type":78,"value":79,"toc":627},"minimark",[80,94,131,139,151,156,303,327,331,339,375,382,399,404,407,483,494,498,510,546,549,570,623],[39,81,82,83,87,88,93],{},"Kirby Helpers loads ",[84,85,86],"code",{},".env"," files with ",[46,89,92],{"href":90,"rel":91},"https:\u002F\u002Fgithub.com\u002Fvlucas\u002Fphpdotenv",[50],"phpdotenv",", so the file follows its syntax:",[95,96,101],"pre",{"className":97,"code":98,"filename":86,"language":99,"meta":100,"style":100},"language-bash shiki shiki-themes github-light github-light github-dark","KIRBY_DEBUG=true\nMAIL_FROM=noreply@example.com\n","bash","",[84,102,103,120],{"__ignoreMap":100},[104,105,108,112,116],"span",{"class":106,"line":107},"line",1,[104,109,111],{"class":110},"sxrX7","KIRBY_DEBUG",[104,113,115],{"class":114},"s8jYJ","=",[104,117,119],{"class":118},"sIIMD","true\n",[104,121,123,126,128],{"class":106,"line":122},2,[104,124,125],{"class":110},"MAIL_FROM",[104,127,115],{"class":114},[104,129,130],{"class":118},"noreply@example.com\n",[132,133,135,136],"h2",{"id":134},"load-the-file-in-configphp","Load the File in ",[84,137,138],{},"config.php",[39,140,141,142,144,145,148,149,73],{},"Load the file at the top of ",[84,143,138],{},", so the options below it can read its values. ",[84,146,147],{},"Env::load()"," takes the directory that holds the file. A second argument names a file other than ",[84,150,86],{},[39,152,153,155],{},[84,154,147],{}," throws when the file is missing; where production sets its variables in the server environment, load it only when it exists:",[95,157,162],{"className":158,"code":159,"filename":160,"language":161,"meta":100,"style":100},"language-php shiki shiki-themes github-light github-light github-dark","use JohannSchopplich\\Helpers\\Env;\n\n$root = dirname(__DIR__, 2);\n\nif (is_file($root . '\u002F.env')) {\n    Env::load($root);\n}\n\nreturn [\n    'debug' => env('KIRBY_DEBUG', false)\n];\n","site\u002Fconfig\u002Fconfig.php","php",[84,163,164,176,182,208,213,236,252,258,263,272,297],{"__ignoreMap":100},[104,165,166,169,173],{"class":106,"line":107},[104,167,168],{"class":114},"use",[104,170,172],{"class":171},"sBjJW"," JohannSchopplich\\Helpers\\Env",[104,174,175],{"class":110},";\n",[104,177,178],{"class":106,"line":122},[104,179,181],{"emptyLinePlaceholder":180},true,"\n",[104,183,185,188,190,193,196,199,202,205],{"class":106,"line":184},3,[104,186,187],{"class":110},"$root ",[104,189,115],{"class":114},[104,191,192],{"class":171}," dirname",[104,194,195],{"class":110},"(",[104,197,198],{"class":171},"__DIR__",[104,200,201],{"class":110},", ",[104,203,204],{"class":171},"2",[104,206,207],{"class":110},");\n",[104,209,211],{"class":106,"line":210},4,[104,212,181],{"emptyLinePlaceholder":180},[104,214,216,219,222,225,228,230,233],{"class":106,"line":215},5,[104,217,218],{"class":114},"if",[104,220,221],{"class":110}," (",[104,223,224],{"class":171},"is_file",[104,226,227],{"class":110},"($root ",[104,229,73],{"class":114},[104,231,232],{"class":118}," '\u002F.env'",[104,234,235],{"class":110},")) {\n",[104,237,239,242,245,249],{"class":106,"line":238},6,[104,240,241],{"class":171},"    Env",[104,243,244],{"class":114},"::",[104,246,248],{"class":247},"snPdu","load",[104,250,251],{"class":110},"($root);\n",[104,253,255],{"class":106,"line":254},7,[104,256,257],{"class":110},"}\n",[104,259,261],{"class":106,"line":260},8,[104,262,181],{"emptyLinePlaceholder":180},[104,264,266,269],{"class":106,"line":265},9,[104,267,268],{"class":114},"return",[104,270,271],{"class":110}," [\n",[104,273,275,278,281,284,286,289,291,294],{"class":106,"line":274},10,[104,276,277],{"class":118},"    'debug'",[104,279,280],{"class":114}," =>",[104,282,283],{"class":247}," env",[104,285,195],{"class":110},[104,287,288],{"class":118},"'KIRBY_DEBUG'",[104,290,201],{"class":110},[104,292,293],{"class":171},"false",[104,295,296],{"class":110},")\n",[104,298,300],{"class":106,"line":299},11,[104,301,302],{"class":110},"];\n",[39,304,305,306,309,310,313,314,316,317,319,320,326],{},"With the Composer install, ",[84,307,308],{},"Env"," and ",[84,311,312],{},"env()"," are autoloaded before Kirby reads ",[84,315,138],{},". A ZIP install loads with the plugins, after ",[84,318,138],{}," – read values with ",[46,321,323],{"href":322},"#load-the-file-on-first-use",[84,324,325],{},"$site->env()"," instead.",[132,328,330],{"id":329},"read-values","Read Values",[39,332,333,335,336,338],{},[84,334,312],{}," reads a variable anywhere once the file is loaded – in ",[84,337,138],{},", templates, snippets, and plugins:",[95,340,343],{"className":158,"code":341,"filename":342,"language":161,"meta":100,"style":100},"\u003C?php $mailFrom = env('MAIL_FROM', 'hello@example.com') ?>\n","site\u002Ftemplates\u002Fdefault.php",[84,344,345],{"__ignoreMap":100},[104,346,347,350,352,355,357,359,361,364,366,369,372],{"class":106,"line":107},[104,348,349],{"class":114},"\u003C?",[104,351,161],{"class":171},[104,353,354],{"class":110}," $mailFrom ",[104,356,115],{"class":114},[104,358,283],{"class":247},[104,360,195],{"class":110},[104,362,363],{"class":118},"'MAIL_FROM'",[104,365,201],{"class":110},[104,367,368],{"class":118},"'hello@example.com'",[104,370,371],{"class":110},") ",[104,373,374],{"class":114},"?>\n",[39,376,377,378,381],{},"A missing variable returns the default, which can be a closure that runs only then. A variable set to an empty value returns ",[84,379,380],{},"''",", not the default.",[39,383,384,385,309,388,391,392,395,396,398],{},"A variable already set in the server environment wins over the same name in the file. Loaded values are written to ",[84,386,387],{},"$_ENV",[84,389,390],{},"$_SERVER",", not to ",[84,393,394],{},"getenv()",", so a library that reads ",[84,397,394],{}," does not see them.",[400,401,403],"h3",{"id":402},"value-parsing","Value Parsing",[39,405,406],{},"Four spellings are parsed, in any letter case:",[408,409,410,423],"table",{},[411,412,413],"thead",{},[414,415,416,420],"tr",{},[417,418,419],"th",{},"Value",[417,421,422],{},"Returns",[424,425,426,442,455,469],"tbody",{},[414,427,428,438],{},[429,430,431,434,435],"td",{},[84,432,433],{},"true"," or ",[84,436,437],{},"(true)",[429,439,440],{},[84,441,433],{},[414,443,444,451],{},[429,445,446,434,448],{},[84,447,293],{},[84,449,450],{},"(false)",[429,452,453],{},[84,454,293],{},[414,456,457,465],{},[429,458,459,434,462],{},[84,460,461],{},"null",[84,463,464],{},"(null)",[429,466,467],{},[84,468,461],{},[414,470,471,479],{},[429,472,473,434,476],{},[84,474,475],{},"empty",[84,477,478],{},"(empty)",[429,480,481],{},[84,482,380],{},[39,484,485,486,489,490,493],{},"Numbers stay strings – ",[84,487,488],{},"PORT=8080"," returns ",[84,491,492],{},"'8080'",", so cast it where you need an integer.",[132,495,497],{"id":496},"load-the-file-on-first-use","Load the File on First Use",[39,499,500,501,503,504,506,507,509],{},"Without ",[84,502,147],{}," – as with a ZIP install – ",[84,505,325],{}," loads the file on its first call, then reads like ",[84,508,312],{},":",[95,511,513],{"className":158,"code":512,"filename":342,"language":161,"meta":100,"style":100},"\u003C?php $mailFrom = $site->env('MAIL_FROM', 'hello@example.com') ?>\n",[84,514,515],{"__ignoreMap":100},[104,516,517,519,521,523,525,528,531,534,536,538,540,542,544],{"class":106,"line":107},[104,518,349],{"class":114},[104,520,161],{"class":171},[104,522,354],{"class":110},[104,524,115],{"class":114},[104,526,527],{"class":110}," $site",[104,529,530],{"class":114},"->",[104,532,533],{"class":247},"env",[104,535,195],{"class":110},[104,537,363],{"class":118},[104,539,201],{"class":110},[104,541,368],{"class":118},[104,543,371],{"class":110},[104,545,374],{"class":114},[39,547,548],{},"When the file is missing, it skips loading and returns the default, unless the server environment sets the variable.",[39,550,551,554,555,558,559,562,563,566,567,569],{},[84,552,553],{},"env.path"," sets the directory – Kirby's ",[84,556,557],{},"base"," root when your site defines one, else the folder that holds ",[84,560,561],{},"site"," – and ",[84,564,565],{},"env.filename"," the file name, ",[84,568,86],{}," by default:",[95,571,573],{"className":158,"code":572,"filename":160,"language":161,"meta":100,"style":100},"return [\n    'johannschopplich.helpers' => [\n        'env' => [\n            'filename' => '.env.local'\n        ]\n    ]\n];\n",[84,574,575,581,590,599,609,614,619],{"__ignoreMap":100},[104,576,577,579],{"class":106,"line":107},[104,578,268],{"class":114},[104,580,271],{"class":110},[104,582,583,586,588],{"class":106,"line":122},[104,584,585],{"class":118},"    'johannschopplich.helpers'",[104,587,280],{"class":114},[104,589,271],{"class":110},[104,591,592,595,597],{"class":106,"line":184},[104,593,594],{"class":118},"        'env'",[104,596,280],{"class":114},[104,598,271],{"class":110},[104,600,601,604,606],{"class":106,"line":210},[104,602,603],{"class":118},"            'filename'",[104,605,280],{"class":114},[104,607,608],{"class":118}," '.env.local'\n",[104,610,611],{"class":106,"line":215},[104,612,613],{"class":110},"        ]\n",[104,615,616],{"class":106,"line":238},[104,617,618],{"class":110},"    ]\n",[104,620,621],{"class":106,"line":254},[104,622,302],{"class":110},[624,625,626],"style",{},"html pre.shiki code .sxrX7, html code.shiki .sxrX7{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s8jYJ, html code.shiki .s8jYJ{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sIIMD, html code.shiki .sIIMD{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sBjJW, html code.shiki .sBjJW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .snPdu, html code.shiki .snPdu{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#B392F0}",{"title":100,"searchDepth":122,"depth":122,"links":628},[629,631,634],{"id":134,"depth":122,"text":630},"Load the File in config.php",{"id":329,"depth":122,"text":330,"children":632},[633],{"id":402,"depth":184,"text":403},{"id":496,"depth":122,"text":497},"Load a .env file and read its values in config.php, templates, and plugins, with booleans and null parsed from their spelling.","md",{},{"title":12,"description":635},"ciwk9JwOgw5K_VJQiD7LJ-sFukDUF9-VN_cAyrmmJ2A",[74,641],{"title":16,"path":17,"stem":18,"description":642,"children":-1},"Render description, Open Graph, Twitter Card, JSON-LD, robots, and canonical tags for a page from its fields, its page model, or global defaults.",1791534959999]