Laravel 5应用程序密钥 [英] Laravel 5 Application Key

查看:121
本文介绍了Laravel 5应用程序密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Laravel的新手.我今晚才刚开始.实际上,我有以下代码:

I am new to Laravel. I just started it tonight. Actually, I have the following code:

'key' => env('APP_KEY', 'SomeRandomString'),

xampp/htdocs/laravel/blog/config/app.php 中.
我想通过cmd将密钥更改为32位,如下所示:

In xampp/htdocs/laravel/blog/config/app.php.
I want to change this key to 32-bit by cmd as:

xampp\htdocs\laravel/blog>php artisan key:generate 

它生成密钥,但无法在 xampp/htdocs/laravel/blog/config/app.php 中替换/更新.

It generates the key but could not replace/update in xampp/htdocs/laravel/blog/config/app.php.

推荐答案

app.php'key' => env('APP_KEY', 'SomeRandomString'),中的这一行表示可以在.env文件中的.

This line in your app.php, 'key' => env('APP_KEY', 'SomeRandomString'),, is saying that the key for your application can be found in your .env file on the line APP_KEY.

基本上,它告诉Laravel首先在.env文件中查找密钥,如果没有,则使用'SomeRandomString'.

Basically it tells Laravel to look for the key in the .env file first and if there isn't one there then to use 'SomeRandomString'.

使用php artisan key:generate时,它将为您的.env文件而不是app.php文件生成新密钥.

When you use the php artisan key:generate it will generate the new key to your .env file and not the app.php file.

正如kotapeter所说,您的.env将位于您的Laravel根目录中,并且可能被隐藏; xampp/htdocs/laravel/blog

As kotapeter said, your .env will be inside your root Laravel directory and may be hidden; xampp/htdocs/laravel/blog

这篇关于Laravel 5应用程序密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆