当前位置:网站首页>Lavarel之环境配置 .env
Lavarel之环境配置 .env
2022-07-07 11:48:00 【全栈程序员站长】
.env 文件位于项目根目录下,作为全局环境配置文件。
1. 配置参数
// 运行环境名称 APP_ENV=local // 调试模式,开发阶段启用,上线状态禁用。 APP_DEBUG=true // 敏感信息加密密钥,可使用 php artisan key:generate 重新生成。 APP_KEY= // 项目根目录 APP_URL=http://localhost // 缓存驱动,默认使用文件作为缓存。 CACHE_DRIVER=file // 回话驱动,默认使用文件存储SESSION。 SESSION_DRIVER=file // 队列驱动,默认使用同步模式。 QUEUE_DRIVER=sync // Redis高性能key-value数据库,使用内存存储,用于数据持久化。 REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 // 数据库配置项 DB_HOST=127.0.0.1//数据库主机名 DB_PORT=3306//数据库端口 DB_DATABASE=homestead//数据库名称 DB_USERNAME=homestead//数据库登录账户 DB_PASSWORD=secret//数据库登录密码 [疑问].env 环境配置是如何在项目中工作的呢? .env文件实际是对/config/目录下的通用配置做提取。查看/config/app.php可发现,系统提供env()用于读取.env文件配置。
[疑问].env的数据库配置并不存在数据表前缀的设置,该怎么办呢? 查看/config/database.php文件中提供prefix字段可进行修改,可以在.env文件中新增DB_PREFIX配置,并在/config/database.php修改prefix选项为env(DB_PREFIX,'')。
2. 获取配置
env() 使用env()可获取.env文件中的全局通用配置。 例如:env('DB_HOST')
config() 使用config()可获取/config/目录下项目的配置项信息。 例如:config('database.connections.mysql.prefix')
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/113301.html原文链接:https://javaforall.cn
边栏推荐
- PostgreSQL array type, each splice
- 2022-7-6 Leetcode 977. Square of ordered array
- [high frequency interview questions] difficulty 2.5/5, simple combination of DFS trie template level application questions
- 2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
- 供应链供需预估-[时间序列]
- 华为镜像地址
- Ogre introduction
- Data refresh of recyclerview
- 一文读懂数仓中的pg_stat
- 得物客服热线的演进之路
猜你喜欢

提升树莓派性能的方法

Show the mathematical formula in El table

2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
![供应链供需预估-[时间序列]](/img/2c/82d118cfbcef4498998298dd3844b1.png)
供应链供需预估-[时间序列]

Realize the IP address home display function and number home query

Final review notes of single chip microcomputer principle

Ogre introduction

10 pictures open the door of CPU cache consistency

Battle Atlas: 12 scenarios detailing the requirements for container safety construction

Esp32 ① compilation environment
随机推荐
How far can it go to adopt a cow by selling the concept to the market?
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
Show the mathematical formula in El table
Introduction to database system - Chapter 1 introduction [conceptual model, hierarchical model and three-level mode (external mode, mode, internal mode)]
Summary of import, export, backup and recovery of mongodb
[1] ROS2基础知识-操作命令总结版
C语言数组相关问题深度理解
Cinnamon taskbar speed
PHP - laravel cache
Ogre introduction
交付效率提升52倍,运营效率提升10倍,看《金融云原生技术实践案例汇编》(附下载)
数字ic设计——SPI
[1] Basic knowledge of ros2 - summary version of operation commands
Mongodb meets spark (for integration)
Simple and easy-to-use code specification
Read PG in data warehouse in one article_ stat
Mongodb replication (replica set) summary
. Net core about redis pipeline and transactions
JS slow motion animation principle teaching (super detail)