mallka / yii2-webshell
一个允许运行yii或其他控制台命令并创建自己命令的web shell。
2.0.0
2016-03-04 01:01 UTC
Requires
- bower-asset/jquery.terminal: ~0.8.8
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-13 17:43:54 UTC
README
注意:该包是从 samdark/yii2-webshell 分支出来的
我们做了哪些更改
- 允许运行其他控制台命令
- 由于一些时间以来bower目录不同,将jquery.terminal移动到asset文件夹中
- 更改了Asset类的源路径,因此不再需要设置别名配置。
Yii 2.0 web shell
Web shell允许使用浏览器运行yii
控制台命令。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令:
php composer.phar require --prefer-dist mallka/yii2-webshell "dev-master"
或者
"mallka/yii2-webshell": "dev-master"
将以下内容添加到您的composer.json
文件的require部分:
配置
要使用web shell,将其作为模块包含在应用程序配置中,如下所示
return [ 'modules' => [ 'webshell' => [ 'class' => 'mallka\webshell\Module', // 'yiiScript' => Yii::getAlias('@root'). '/yii', // adjust path to point to your ./yii script ], ], // ... other application configuration ]
使用上述配置,您将能够使用URL https:///path/to/index.php?r=webshell
在浏览器中访问web shell
访问控制
默认情况下,访问限制为本地IP。可以通过allowedIPs
属性进行更改。此外,还有checkAccessCallback
可用于引入自定义访问控制。
return [ 'modules' => [ 'webshell' => [ 'class' => 'mallka\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; }, //allow to run other commands,default is true, 'unlimit'=>false, //unsupport command 'unsupportCommands'=>['top','ping'], ], ], // ... other application configuration ]
限制
由于Web的请求-响应性质,Web shell无法进行交互式操作。因此,您应该禁用命令的交互模式。