在 laravel 中使用 php artisan 优化后无法获取 env 文件属性
can not get env file attribute after using php artisan optimize in laravel
我像这样从 env 文件中获取属性值
{{env('PUSHER_APP_KEY')}}
当我使用 php artisan optimize
命令时它停止工作
然后我又得用php artisan config:clear
有什么解决办法吗?
最好在 config folder
中创建一个 config
文件
例如将 config
文件命名为 constant.php
<?php
return [
'pusher_app_key'=>env('PUSHER_APP_KEY')
];
然后就可以这样访问了
{{config('constant.pusher_app_key')}}
一旦你创建了 config:cache,它就不会从 env 文件中读取。
我像这样从 env 文件中获取属性值
{{env('PUSHER_APP_KEY')}}
当我使用 php artisan optimize
命令时它停止工作
然后我又得用php artisan config:clear
有什么解决办法吗?
最好在 config folder
config
文件
例如将 config
文件命名为 constant.php
<?php
return [
'pusher_app_key'=>env('PUSHER_APP_KEY')
];
然后就可以这样访问了
{{config('constant.pusher_app_key')}}
一旦你创建了 config:cache,它就不会从 env 文件中读取。