zoukankan      html  css  js  c++  java
  • Laravel Configuration

    Introduction

    All of the configuration files for the Laravel framework are stored in the app/config directory. Each option in every file is documented, so feel free to look through the files and get familiar with the options available to you.

    Sometimes you may need to access configuration values at run-time. You may do so using the Config class:

    Accessing A Configuration Value

    Config::get('app.timezone');

    You may also specify a default value to return if the configuration option does not exist:

    $timezone = Config::get('app.timezone', 'UTC');

    Setting A Configuration Value

    Notice that "dot" style syntax may be used to access values in the various files. You may also set configuration values at run-time:

    Config::set('database.default', 'sqlite');

    Configuration values that are set at run-time are only set for the current request, and will not be carried over to subsequent requests.

    Environment Configuration

    It is often helpful to have different configuration values based on the environment the application is running in. For example, you may wish to use a different cache driver on your local development machine than on the production server. It is easy to accomplish this using environment based configuration.

    Simply create a folder within the config directory that matches your environment name, such as local. Next, create the configuration files you wish to override and specify the options for that environment. For example, to override the cache driver for the local environment, you would create a cache.php file inapp/config/local with the following content:

  • 相关阅读:
    MySQL(一)序
    Mockito 小结
    如何入门一个开源软件
    面经
    琐碎的想法(四)键盘布局、快捷键的由来
    琐碎的想法(二)网络协议——人们给计算机的一组“约定”
    Java源码赏析(六)Class<T> 类
    Java随谈(五)Java常见的语法糖
    Java随谈(四)JDK对并发的支持
    Event Loop和宏任务微任务
  • 原文地址:https://www.cnblogs.com/ghgyj/p/4049106.html
Copyright © 2011-2022 走看看