laravel 配置文件_如何使用Laravel配置文件

laravel 配置文件

You discover that storing files on your own server is extra load, so not ideal. You open your web browser and do a google search on "efficient ways to store files". Finally, you decide to use Amazon S3. Since you are a Laravel user, you open config/filesystems.php, and then you change the default key value from local to s3, fill in your API keys. Just like that, you have your files uploaded to Amazon S3.

您会发现将文件存储在自己的服务器上是额外的负担,因此并不理想。 您打开网络浏览器,然后在Google上搜索“有效的文件存储方式”。 最后,您决定使用Amazon S3。 由于您是Laravel用户,因此请打开config/filesystems.php ,然后将默认密钥值从local更改为s3 ,并填写API密钥。 这样,您就可以将文件上传到Amazon S3。

Magic, no. This is an example of a configurable system, and an example of SOLID programming. By setting some array values in a file, we can get a system to work without breaking anything. This article is not about SOLID, we are here to talk about Laravel configuration files and how to use them.

魔术,不。 这是可配置系统的示例,也是SOLID编程的示例。 通过在文件中设置一些数组值,我们可以使系统正常运行而不会破坏任何内容。 本文不是关于SOLID的,我们在这里谈论Laravel配置文件以及如何使用它们。

Configuration files in Laravel provide an easy way to set options required by parts of our application to work. Laravel has a lot of configuration files in the config directory. We as developers also have the option to create our own configuration file(s).

Laravel中的配置文件提供了一种简单的方法来设置应用程序某些部分正常工作所需的选项。 Laravel在config目录中有很多配置文件。 作为开发人员,我们还可以选择创建自己的配置文件。

何时使用配置文件 ( When to use Config file )

When building a Laravel Package, config files go a long way in helping you build a configurable and functional package.

在构建Laravel软件包时,配置文件在帮助您构建可配置和功能性软件包方面大有帮助。

创建配置文件 ( Creating a Configuration File )

One reason developers love Laravel is the fact that it makes everything simple. Creating configuration files is not an exception to that rule. To create a configuration file, go to the config directory and create a file there. For our example, let's call our file social.php. After creating the file, open it and return an empty array. There, we have created a configuration file.

开发人员喜欢Laravel的原因之一是它使一切变得简单。 创建配置文件不是该规则的例外。 要创建配置文件,请转到config目录并在其中创建文件。 对于我们的示例,我们将文件social.php 。 创建文件后,将其打开并返回一个空数组。 在那里,我们创建了一个配置文件。

return [];

添加选项 ( Adding Options )

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值