Yii Framework Forum: [COMPONENT] Extension - Yii Framework Forum

Jump to content

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

[COMPONENT] Extension Component that automate the extension install process Rate Topic: -----

#1 User is offline   prchakal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 92
  • Joined: 20-January 10

Posted 05 February 2010 - 01:42 PM

Hi,

I think that Yii only left this feature, so i start the creation process.

A command that automate the extension install process.

Then, here is what is necessary on your server:
- ZLib extension (for unpack process - almost all servers has it)
- CURL library (for http process - almost all servers has it)

And here what you need download:
- http://www.yiiframew...nsion/extension

To install this command only extract the files in protected/commands/shell path.
- protected
- commands
- shell
- ExtensionCommand.php
- ... other files

To use the extension:
- Enter in your application path (ex: d:\www\blog\)
- Enter in Yii console:
yiic shell protected\config\main.php
- Start the download process, this is the hardest part:
extension install swfobject

You will ask, "but how this magic is done?":
1 - Your extension last file version have to has the filename: <extension>_last.zip uploaded on extension Yii area.

2 - Your zip have to has this structure for your extension:
- <extension> dir
- InitExtension.php (i will explain)
- ... your extension files...

The InitExtension file, is a normal class, that have the public method "run", that is automatically called when the extension is downloaded and unpacked.

If you download the swfobjectextension, you will see the example file and how it works, is basically this:

<?php

class InitExtension extends CConsoleCommand
{
    /**
     * Run the main command method
     * @param array     
     */
    public function run($args)
    {
        // prepare some vars
        $files      = array();
        $currentDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
        $destDir    = YiiBase::getPathOfAlias('ext.' . $args[1]) . DIRECTORY_SEPARATOR;
        
        // show debug
        echo("DEBUG: Creating extension dir...\n");
        
        // create dirs
        $this->ensureDirectory($destDir);
        $this->ensureDirectory($destDir . 'assets' . DIRECTORY_SEPARATOR);
        
        // show debug
        echo("DEBUG: Copying extension files...\n");
        
        // build file list
        $files[] = array('source' => $currentDir . 'ESwfObject.php', 
                         'target' => $destDir . 'ESwfObject.php');
                         
        $files[] = array('source' => $currentDir . 'assets' . DIRECTORY_SEPARATOR . 'expressInstall.swf', 
                         'target' => $destDir . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'expressInstall.swf');
                         
        $files[] = array('source' => $currentDir . 'assets' . DIRECTORY_SEPARATOR . 'swfobject.js', 
                         'target' => $destDir . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'swfobject.js' );
        
        // copy files
        $this->copyFiles($files);        
    }
}



So, i think that this ExtensionCommand will help us to follow a default structure to automate the extension install process for everyone.

What you think? This is ready!

And dont forget, you only need execute this command to install an extension:
extension install <extension-name>

Be sure that the extension is compatible with it.

Please, if you will post an extension you can follow this structure to help this process and specify in your description that is compatible with it.

License: FREE - BSD LICENSE
0

#2 User is offline   ekerazha 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 526
  • Joined: 10-October 08
  • Location:European Union

Posted 06 February 2010 - 05:03 AM

Great job! I planned to code a frontend to upload/install extensions from a web page, maybe I can re-use some of your code.
Yii user #37
0

#3 User is offline   Seal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 126
  • Joined: 02-February 10

Posted 09 February 2010 - 05:52 AM

HI Pradhan,

following your instruction,I get the following cmd error;

Fatal error: Call to undefined function curl_init() in C:\xamp....\commands\shell\ExtensionCommand.php on line 134

After Enabling Curl...

I got the following errors in the attachment below...Any suggestion, ideas or point in the right direction appreciated.

Thanks
Sylvester La-Tunje

Posted Image
0

#4 User is offline   prchakal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 92
  • Joined: 20-January 10

Posted 09 February 2010 - 06:24 AM

Hi,

If you already have installed CURL, restart your apache/php and create a php file with code:

<?php
    phpinfo();
?>


Open this file in your browser and search for CURL section in blue to see if is enabled.

If enabled, try again the extension command.

I have attached an image to you see the section on phpinfo file.

If not work, post your PHPINFO result here.

Attached File(s)

  • Attached File  curl.png (2.85K)
    Number of downloads: 51

1

#5 User is offline   Seal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 126
  • Joined: 02-February 10

Posted 09 February 2010 - 08:39 AM

View Postprchakal, on 09 February 2010 - 06:24 AM, said:

Hi,

If you already have installed CURL, restart your apache/php and create a php file with code:

<?php
    phpinfo();
?>


Open this file in your browser and search for CURL section in blue to see if is enabled.

If enabled, try again the extension command.

I have attached an image to you see the section on phpinfo file.

If not work, post your PHPINFO result here.


Sorry to confuse you. My problem is the error in the cmd window attached...in my last post :)
Sylvester La-Tunje

Posted Image
0

#6 User is offline   prchakal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 92
  • Joined: 20-January 10

Posted 09 February 2010 - 09:45 AM

Oh man, ok, no problem.

The warnings was solved and i post the new version with this warnings fixed.

Thanks :)

Class fixes:

$InitExtension = new InitExtension(parent::getName(), parent::getCommandRunner());

0

#7 User is offline   Seal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 126
  • Joined: 02-February 10

Posted 09 February 2010 - 09:58 AM

View Postprchakal, on 09 February 2010 - 09:45 AM, said:

Oh man, ok, no problem.

The warnings was solved and i post the new version with this warnings fixed.

Thanks :)

Class fixes:

$InitExtension = new InitExtension(parent::getName(), parent::getCommandRunner());


Thanks will try later and give you feedback
Sylvester La-Tunje

Posted Image
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