当前位置:网站首页>Environment configuration of lavarel env

Environment configuration of lavarel env

2022-07-07 13:51:00 Full stack programmer webmaster

.env The file is located in the root directory of the project , As a global environment configuration file .

1. Configuration parameters

//  Running environment name  APP_ENV=local //  Debug mode , Development phase enabled , Online status is disabled . APP_DEBUG=true //  Sensitive information encryption key , You can use  php artisan key:generate  To regenerate the . APP_KEY= //  Project root  APP_URL=http://localhost //  Cache drive , File is used as cache by default . CACHE_DRIVER=file //  Call back drive , Use file storage by default SESSION. SESSION_DRIVER=file //  Queue driven , Synchronous mode is used by default . QUEUE_DRIVER=sync // Redis High performance key-value database , Use memory storage , For data persistence . REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 //  Database configuration items  DB_HOST=127.0.0.1// Database host name  DB_PORT=3306// Database port  DB_DATABASE=homestead// Database name  DB_USERNAME=homestead// Database login account  DB_PASSWORD=secret// Database login password  

[ doubt ].env How does the environment configuration work in the project ? .env The document is actually right /config/ Extract the general configuration under the directory . see /config/app.php Can be found , The system provides env() For reading .env File configuration .

[ doubt ].env The database configuration of does not have the setting of data table prefix , What to do ? see /config/database.php Provided in the document prefix Fields can be modified , Can be in .env Add... To the file DB_PREFIX To configure , And in /config/database.php modify prefix The options are env(DB_PREFIX,'').

2. Get configuration

env() Use env() Available .env Global general configuration in the file . for example :env('DB_HOST')

config() Use config() Available /config/ Configuration item information of items under the directory . for example :config('database.connections.mysql.prefix')

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113301.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071146403255.html