Import Php Library From Github

Hey everyone!

I made a PHP library and created a github repo for it.

I use Composer (composer.phar) in my Yii project.

My library has a constructor that accepts some parameters.

I want to include my library to my project using Composer and set up parameters for constructor of my library in my main.php config:


'components' => array(

    'mylib' => array(

        //'class' => 'vendor.mylibpath.MyLib',

        'param1' => 'my 1st param',

        'param2' => 'my 2nd param',

    ),

)

How should I do this trick?

Maybe:


class MyWrapper extends CApplicationComponent

{

   private $lib;


   public $param1;

   public $param2;


   public getLib()

   {

        return $this->lib;

   }


   public function init()

   {

        $this->lib = new Lib($this->param1, $this->param2);

   }

}

You might want to have a look at the extensions by our very own Chris83. AFAIK, all his extensions are available via Composer and they are on Github as well. You might learn what you need to know from his sources :)

His extensions are very Yii-specific))

My library is not Yii specific and can be used in every PHP project.

But thanks anyway!

Ah, so you will require a wrapper, won’t you? Well, good luck :)

Yeah, I did a wrapper:


class MylibWrapper extends CApplicationComponent

{

    private $client;

    

    public $params;

    

    public function getClient()

    {

        return $this->client;

    }

    

    public function init()

    {        

        $this->client = new Mylib($this->params);

    }

}