我阅读了文档,但无法了解如何从
Security.salt
中的 app.php
获取 Cakephp 3
值。我正在尝试像这样得到它
$salt = Configure::read('Security.salt');
导入以下库
use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig;
请帮忙。
Cakephp version is 3.4
Configure::Read('Security.salt')
在 cakephp 3 版本工作之前,将在 cakephp 3.x 中返回空白值。
为了从配置文件中读取盐,您需要包含安全命名空间:
use Cake\Utility\Security;
您可以使用以下方法检索盐的值:
Security::salt()
示例-
echo Security::salt();
// Security::salt() is deprecated as of 3.5.0 Use getSalt()/setSalt() instead.
<?php
use Cake\Utility\Security;
function yourMethod() {
echo Security::getSalt();
}