php 如何在 Laravel .env 文件中发表评论?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32368016/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:56:39  来源:igfitidea点击:

How to comment in laravel .env file?

phplaravellaravel-5environment-variables

提问by Akshay Khale

I am working on a project in Laravel where I am storing some settings in .env file setting like few parameters for testing purpose and few parameters are for live working so I was just checking that is there any way to comment in .env file of Laravel.

我正在 Laravel 的一个项目中工作,我将一些设置存储在 .env 文件设置中,例如用于测试目的的几个参数和用于实时工作的参数,所以我只是检查是否有任何方法可以在 Laravel 的 .env 文件中进行评论.

Here is an example

这是一个例子

/* Test Settings */
ACCESS_KEY=qwsdr
ACCESS_TOKEN=Bgcvfsx

/* Live Settings */
ACCESS_KEY=985AsdefG
ACCCESS_TOKEN=LFP994kL

回答by Joel Hinz

You use hash commenting:

您使用哈希注释:

# Test Settings
ACCESS_KEY=qwsdr
ACCESS_TOKEN=Bgcvfsx

# Live Settings
ACCESS_KEY=985AsdefG
ACCCESS_TOKEN=LFP994kL

Documentation: https://github.com/vlucas/phpdotenv#comments

文档:https: //github.com/vlucas/phpdotenv#comments

回答by PtrTon

Please note that as of Laravel 5.8 comment parsing in values has changed.

请注意,从 Laravel 5.8 开始,值中的注释解析已更改

In Laravel 5.7 an .env file containing ENV_VALUE=foo#barwould evaluate to foo#bar.

在 Laravel 5.7 中,包含 .env 文件的ENV_VALUE=foo#bar计算结果为foo#bar.

In Laravel 5.8 the same .env file would evaluate to fooinstead, with #barbeing seen as a comment.

在 Laravel 5.8 中,相同的 .env 文件将foo改为评估为,#bar被视为注释。

To use the #character in a value, double quote the entire value like so ENV_VALUE="foo#bar".

#在值中使用字符,请将整个值用双引号括起来,就像这样ENV_VALUE="foo#bar"