gpt4 book ai didi

yii2 - Yii 2.0 启用对 gii 的远程访问

转载 作者:行者123 更新时间:2023-12-04 19:05:01 24 4
gpt4 key购买 nike

简单的问题,试图在 yii 2 中启用对 gii 的远程访问 - 文档说 http://www.yiiframework.com/doc-2.0/guide-start-gii.html

Note: If you are accessing Gii from a machine other than localhost, the access will be denied by default for security purpose. You can configure Gii to add the allowed IP addresses as follows,

'gii' => [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs
],

问题是,它没有说明在哪里添加这个 - 猜测 config/web.php

但在哪个部分?

最佳答案

2个地方你需要添加这个。

通常在你的 main-local.php 中是这样完成的

if (!YII_ENV_TEST) {
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}

因此,您需要在配置的引导部分和模块部分中添加 gii。这将基本上将它们从您的 config/main.php 附加到数组中
返回 [
'id' => '应用后端',
'basePath' => 目录名( 目录 ),
'controllerNamespace' => '后端\ Controller ',
'引导' => ['日志'],
'模块' => [
],
],

在您提供的链接上,请查看上方。你应该做:
if (YII_ENV_DEV) {
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs
];
}

关于yii2 - Yii 2.0 启用对 gii 的远程访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27306727/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com