拉威尔的官方网站建议我们把.把它变成Git,对其他人也是如此.

为什么?我觉得,一旦你忘记了如何设置配置,以后使用它会非常方便.

推荐答案

Your .env file contains very sensitive information (your app key at the very least). You do not want this in version control where everybody can see this information and possibly use it to attack your site.
Think about database information which might be stored in there or email keys or passwords. Furthermore it is likely that the information which you use in your .env file also needs to change between environments so you will need to change values anyways.

What should you instead do?
Make a file .env.example in this file you place all the keys of your .env.
ex.

APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

在这里,您可以看到一个文件,其中提供了想要使用您的代码的人的所有必要信息,但没有任何敏感信息.然后有人可以把这个.env.example复制到.env,然后改变数值.

Laravel相关问答推荐

如何在Vite和Rollup中完全禁用分块?

分页计数(*)查询问题

调用字符串上的成员函数

1 子编译中的警告(使用'stats.children:true'和'--stats-children'了解更多详细信息)

Laravel | 使用select查询

Laravel 连接表

Laravel 如何处理来自浏览器的 PUT 请求?

Laravel 有Many Many to Many To One Eloquent

Laravel 5 - 手动分页

Laravel 中未加密的 cookie

在 Laravel 中无效后防止重定向到主页

使用 laravel eloquent 关系检索除 NULL 之外的所有记录

将图标添加到 Laravelcollective 提交按钮

Laravel 5 环境配置数组?

判断输入是否来自控制台

在 Laravel 中包含 bootstrap 程序

Laravel 5.4 Vue.JS 无法挂载组件:未定义模板或渲染函数

如何以及在哪里可以使用 laravel 存储图像?

在哪里放置 Blade::extend

是否可以在 Laravel 的不同数据库中引用外键?