[COMPONENT] Extension


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

A command that automate the extension install process.

[color="#FF0000"]Then, here is what is necessary on your server:[/color]

  • ZLib extension (for unpack process - almost all servers has it)

  • CURL library (for http process - almost all servers has it)

[color="#FF0000"]And here what you need download:[/color]

[color="#FF0000"]To install this command only extract the files in protected/commands/shell [/color]path.

  • protected

  • commands

    • shell

      • ExtensionCommand.php

      • other files

[color="#FF0000"]To use the extension:[/color]

  • 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

[color="#FF0000"]You will ask, "but how this magic is done?":[/color]

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:

  - &lt;extension&gt; 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:


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 . '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




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.


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.

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.



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




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 :)

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