samdark/yii2-webshell

一个允许运行yii控制台命令并创建自己命令的web壳。

资助包维护!
samdark
Patreon

安装数: 65,792

依赖项: 0

建议者: 0

安全: 0

星标: 226

关注者: 33

分支: 36

开放问题: 5

类型:yii2-extension

2.0.0 2016-03-04 01:01 UTC

This package is auto-updated.

Last update: 2024-08-24 03:10:34 UTC


README

Web壳允许通过浏览器运行yii控制台命令。

安装

安装此扩展的首选方式是通过composer

运行以下命令之一

php composer.phar require --prefer-dist samdark/yii2-webshell "~2.0"

或添加

"samdark/yii2-webshell": "~2.0"

到您的composer.json文件的require部分。

配置

要使用web壳,将其作为模块包含在应用程序配置中,如下所示

return [
    'modules' => [
        'webshell' => [
            'class' => 'samdark\webshell\Module',
            // 'yiiScript' => Yii::getAlias('@root'). '/yii', // adjust path to point to your ./yii script
        ],
    ],

    // ... other application configuration
]

使用上述配置,您将能够通过URL http://localhost/path/to/index.php?r=webshell 在浏览器中访问web壳

访问控制

默认情况下,访问受限于本地IP。可以通过allowedIPs属性进行更改。此外,checkAccessCallback可用于引入自定义访问控制

return [
    'modules' => [
        'webshell' => [
            'class' => 'samdark\webshell\Module',
            // 'yiiScript' => Yii::getAlias('@root'). '/yii', // adjust path to point to your ./yii script
            'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.2'],
            'checkAccessCallback' => function (\yii\base\Action $action) {
                // return true if access is granted or false otherwise
                return true;
            }
        ],
    ],

    // ... other application configuration
]

限制

由于Web的请求-响应特性,Web壳无法进行交互式操作。因此,您应该禁用命令的交互模式。