PHPackages                             yiiext/webshell-module - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. yiiext/webshell-module

ActiveYii-extension[CLI &amp; Console](/categories/cli)

yiiext/webshell-module
======================

Web shell for Yii allows you to run console commands from your browser. Can be useful for both no-ssh webservers and console-style administration modules.

062JavaScript

Since Nov 18Pushed 11y ago1 watchersCompare

[ Source](https://github.com/fiberside/webshell-module)[ Packagist](https://packagist.org/packages/yiiext/webshell-module)[ RSS](/packages/yiiext-webshell-module/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Yii web shell
=============

[](#yii-web-shell)

Web shell for Yii allows you to run console commands from your browser. Can be useful for both no-ssh webservers and console-style administration modules.

Yii web shell uses the same config as your web application so if your application works it will work too.

Since we're working in the web environment we don't have STDIN. It means that commands like `yiic migrate` will not work in interactive mode. In case of `migrate`you can turn it off be setting `interactive` to false.

Installing
----------

[](#installing)

To use web shell, you must include it as a module in the application configuration like the following:

```
[php]
return array(
	…
	'modules'=>array(
		'webshell'=>array(
			'class'=>'ext.yiiext.modules.webshell.WebShellModule',
			// when typing 'exit', user will be redirected to this URL
			'exitUrl' => '/',
			// custom wterm options
			'wtermOptions' => array(
				// linux-like command prompt
				'PS1' => '%',
			),
			// additional commands (see below)
			'commands' => array(
				'test' => array('js:function(){return "Hello, world!";}', 'Just a test.'),
			),
			// uncomment to disable yiic
			// 'useYiic' => false,

			// adding custom yiic commands not from protected/commands dir
			'yiicCommandMap' => array(
				'email'=>array(
					'class'=>'ext.mailer.MailerCommand',
					'from'=>'sam@rmcreative.ru',
				),
				'migrate' => array(
					'class' => 'system.cli.commands.MigrateCommand',
					'interactive'=>false,
				),
			),
		),
	),
)

```

With the above configuration, you will be able to access web shell in your browser using the following URL:

If your application is using path-format URLs with some customized URL rules, you may need to add the following URLs in your application configuration in order to access web shell module:

```
[php]
'components'=>array(
    'urlManager'=>array(
        'urlFormat'=>'path',
            'rules'=>array(
                'webshell'=>'webshell',
                'webshell/'=>'webshell/',
                'webshell//'=>'webshell//',
                …other rules…
        ),
    )
)

```

You can then access web shell via:

[http://localhost/path\_to\_webroot/webshell](http://localhost/path_to_webroot/webshell)

Adding custom commands
----------------------

[](#adding-custom-commands)

You can add both shell commands and yiic commands.

Shell commands are configured via commands property of `WebShellModule`:

```
[php]
'commands' => array(
    // js callback as a command
    'test' => array('js:function(tokens){return "Hello, world!";}', 'Just a test.'),

    // ajax callback to http://yourwebsite/post/index?action=cli (will be normalized according to URL rules)
    'postlist' => array(array('/post/index', array('action' => 'cli')), 'Description.'),

    // sticky command handler. One will need to type 'exit' to leave its context.
    'stickyhandler' => array(
        array(
            // optional: called when 'stickyhandler' is typed. Can be either URL array or callback.
            'START_HOOK' => array('/post/index', array('action' => 'start')),
            // optional: called when 'exit' is typed. Can be either URL array or callback.
            'EXIT_HOOK' => "js:function(){ return 'bye!'; }",
            // required: called when parameter is typed. Can be either URL array or callback.
            'DISPATCH' => "js:function(tokens){ return "Hi, Jack!"; }",
            // optional: custom prompt
            'PS1' => 'advanced >',
        ),
        'Advanced command.',
    ),
),

```

Callback for a shell command should look like this:

```
[php]
function actionMyCommandHandler(){
    $tokens = explode(" ", $_GET['tokens']);
    print_r($tokens);
}

```

To learn about creating custom yiic commands you can read "[Console Applications](http://www.yiiframework.com/doc/guide/topics.console)".

Security
--------

[](#security)

There are two module settings that will help you to keep web console secure:

```
[php]
// Allowed IPs, localhost by default. Set to false to allow all IPs.
'ipFilters' => array('127.0.0.1','::1'),
// Valid PHP callback that returns if user should be allowed to use web shell.
// In this example it's valid for PHP 5.3.
'checkAccessCallback' => function($controller, $action){
    return !Yii::app()->user->isGuest;
}

```

Special thanks
--------------

[](#special-thanks)

- [Dimitrios Meggidis](http://www.yiiframework.com/forum/index.php?/user/4786-tydeas-dr/) for a nice idea and for showing me wterm. You can check his [general purpose wterm Yii widget](http://github.com/dmtrs/EWebTerm).
- [Qiang Xue](http://www.yiiframework.com/about/) for Yii itself, and ipFilters routine code.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b906d2f5cf79cea80eab0bc4b33226a415431fbc4bd6406f138e6e5c78b6d5f6?d=identicon)[angel-kulikov](/maintainers/angel-kulikov)

---

Top Contributors

[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (8 commits)")[![im-kulikov](https://avatars.githubusercontent.com/u/888650?v=4)](https://github.com/im-kulikov "im-kulikov (4 commits)")[![cebe](https://avatars.githubusercontent.com/u/189796?v=4)](https://github.com/cebe "cebe (1 commits)")

### Embed Badge

![Health badge](/badges/yiiext-webshell-module/health.svg)

```
[![Health](https://phpackages.com/badges/yiiext-webshell-module/health.svg)](https://phpackages.com/packages/yiiext-webshell-module)
```

###  Alternatives

[illuminate/console

The Illuminate Console package.

13046.0M6.5k](/packages/illuminate-console)[styleci/cli

The CLI tool for StyleCI

71470.5k9](/packages/styleci-cli)[winbox/args

Windows command-line formatter

20720.9k21](/packages/winbox-args)[tomatophp/filament-artisan

Simple but yet powerful library for running some artisan commands for FilamentPHP

3275.4k1](/packages/tomatophp-filament-artisan)[thettler/laravel-console-toolkit

This Package provides some usefully console features like the attribute syntax for arguments and options, validation, auto ask and casting.

324.1k](/packages/thettler-laravel-console-toolkit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
