San*_*ari 22
您可以在config文件夹中创建文件.例如
config
|- constants.php
Run Code Online (Sandbox Code Playgroud)
在constants.php中,您可以定义全局变量
<?php
return [
/*
|--------------------------------------------------------------------------
| User Defined Variables
|--------------------------------------------------------------------------
|
| This is a set of variables that are made specific to this application
| that are better placed here rather than in .env file.
| Use config('your_key') to get the values.
|
*/
'company_name' => env('COMPANY_NAME','Acme Inc'),
'company_email' => env('COMPANY_email','contact@acme.inc'),
];
Run Code Online (Sandbox Code Playgroud)
您可以使用以下两个函数之一访问这些变量:
Config::get('constants.company_name')
config('constants.company_name')
Run Code Online (Sandbox Code Playgroud)
对于Blade也是如此:
{{ config('constants.company_email') }}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13024 次 |
| 最近记录: |