Yii Framework Forum: [Module] Yii web shell - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Module] Yii web shell Rate Topic: ***** 1 Votes

#1 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,308
  • Joined: 17-January 09
  • Location:Russia

Posted 24 September 2010 - 07:16 PM

Posted Image

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.

- Source code
- Module and docs
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
1

#2 User is offline   imehesz 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 701
  • Joined: 13-June 09
  • Location:Jacksonville, FL

Posted 25 September 2010 - 12:13 AM

hi,

this is awesome.

thanks, SamDark!

--iM
It’s done, the great act of creation.
The maker rests. The wheel’s in motion.
-- Imre Madách

check out Yii Theme Factory at http://yii.themefactory.net
0

#3 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 633
  • Joined: 29-November 08
  • Location:Paris, France

Posted 25 September 2010 - 05:53 AM

This is a great !! .. good idea samdark !
I've tried it but after install, I only get a black blank page and that's it:

<html> 
<head> 
    <meta charset="utf-8"> 
    <link rel="stylesheet" type="text/css" href="/project/yii-1.1.4/assets/6cca1998/wterm.css" /> 
<script type="text/javascript" src="/project/yii-1.1.4/assets/75770a22/jquery.js"></script> 
<script type="text/javascript"> 
/*<![CDATA[*/
var webshell = {'wtermOptions':{'WIDTH':'100%','HEIGHT':'100%','WELCOME_MESSAGE':'Welcome to Yii web shell. Type <strong>help<\/strong> for the list of available commands.','PS1':'%','TERMINAL_CLASS':'terminal','PROMPT_CLASS':'prompt','CONTENT_CLASS':'content','THEME_CLASS_PREFIX':'theme_','DEFAULT_THEME':'webshell','HIGHLIGHT_CLASS':'highlighted','KEYWORD_CLASS':'keyword'},'commands':{'test':function(){return "Hello, world!";},'yiic':'http://localhost/project/yii-1.1.4/index.php?r=webshell/default/yiic'},'helpText':'test\tJust a test.\nyiic\tAllows to run <strong>yiic<\/strong> commands.\nclear\tClear screen.\nexit\tExit console.','exitUrl':'http://localhost/project/yii-1.1.4/index.php'};
/*]]>*/
</script> 
<title><?=$this->pageTitle?></title> 
</head> 
<body> 
<script type="text/javascript" src="/project/yii-1.1.4/assets/6cca1998/wterm.jquery.js"></script> 
<script type="text/javascript" src="/project/yii-1.1.4/assets/6cca1998/webshell.js"></script> 
</body> 
</html>

Here is the module configuration :


	'modules'=>array(
        'webshell'=>array(
            'class'=>'application.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',
                ),
            ),
        ),
	),


What am i doing wrong ?
Thanks
Posted Image
0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,308
  • Joined: 17-January 09
  • Location:Russia

Posted 25 September 2010 - 06:06 AM

Try using
    'modules'=>array(
        'webshell'=>array(
            'class'=>'application.modules.webshell.WebShellModule',
            // when typing 'exit', user will be redirected to this URL
            'exitUrl' => '/',
         ),
    ),

Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#5 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 633
  • Joined: 29-November 08
  • Location:Paris, France

Posted 25 September 2010 - 06:18 AM

same result : blank black page
0

#6 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,308
  • Joined: 17-January 09
  • Location:Russia

Posted 25 September 2010 - 06:50 AM

What is your browser? I've tested it with FF and Opera only.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#7 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 633
  • Joined: 29-November 08
  • Location:Paris, France

Posted 25 September 2010 - 07:03 AM

FF 3.6.9 and also tried with Chrome 6.7.472.

.. I found what the problem is : you are using the shortag (<?=) to render the layout, and my environment does not use it. I've modified views/layouts/webShell.php and now it works fine.
Thanks for your help .... and again this is a great extension !!

8)
0

#8 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,308
  • Joined: 17-January 09
  • Location:Russia

Posted 26 September 2010 - 06:28 PM

Thanks. Fixed.

Updated links in the first post.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#9 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,013
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 27 September 2010 - 05:44 AM

Cool stuff!

One note that came to my mind when looking a the sources: You define a global js var named "commands" in the global namespace here. Nothing wrong with that except that it's a very common name and a potential source for clashes with other js libs.

Since this module is still young, maybe it's still time to change that to something more unique like "yiiwebshellcommands"?
0

#10 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,308
  • Joined: 17-January 09
  • Location:Russia

Posted 27 September 2010 - 10:45 AM

Thanks, fixed: http://code.google.c...ets/webshell.js
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#11 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 26 August 2011 - 07:12 PM

Really awesome module! :D

I have one question though:

How do I add the 'migrate' command?

I tried to add it by using this:
 'yiicCommandMap' => array(
     'migrate'=>array(
         'class'=>'cli.MigrateCommand',                 
	),
 ), 

That really doesn't work.
I get 'migrate' among the available yiic commands but it does nothing. :)

I hacked around by simply adding all commands from yii.cli.commands so that action Yiic in the default controller becomes:
	function actionYiic() {
    	$tokens = explode(" ", $_GET['tokens']);
    	$commandPath = Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'commands';
    	$runner = new CConsoleCommandRunner();
    	$runner->commands = $this->getModule()->yiicCommandMap;
    	$runner->addCommands($commandPath);
    	$commandPath = Yii::getFrameworkPath() . DIRECTORY_SEPARATOR . 'cli' . DIRECTORY_SEPARATOR . 'commands';
    	$runner->addCommands($commandPath);

    	ob_start();
    	$runner->run($tokens);

    	echo htmlentities(ob_get_clean(), null, Yii::app()->charset);
	}

That adds other not wanted commands, but it works.
I can now use yiic migrate on hosts without shell access.
I'd still like to know how you do it properly. ;)
"Less noise - more signal"
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users