Yii 2.0: How to create yii2 extension and push to github and register into packagist to allow end user install from composer

2 followers

1. Create Extension in yii2.

As for this step, you can refer to Create Extension

In short, you can use gii to create extension after read above article. Just be care to change the output as

@app/vendor/yourname

change the namespace as

yourname\yourwidgetname\

2. Install github in you computer.

I use window. So you can google/baidu to search msysgit. It is a window version github. You should be able right click folder and find "Git Bash", "Git Gui", "Git Init Here" and so on menu after you success install msysgit.

3. Link your widget to github

You can link your github account now.

$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"

And then add files.

git add <file1>
git add <file2>
git status
git commit -m "your comment"

Remote github.

$ ssh-keygen -t rsa -C "youremail@example.com"

You will find .ssh dir in you home dir, and find id_rsa和id_rsa.pub You can tell id-rsa.pub to everyone.

Login github with your browser ==> "Account Setting" ==> "SSH keys" ==> "Add SSH key", and paste your id-rsa.pub content in key, as for title, you can type any.

After that

$ git remote add origin git@github.com:youraccount/yourrepository.git
$ git push -u origin master
it will need input your github account and pass since use -u

In future, you only need below
$ git push origin master

4. Register your github repository into packagist

Don't forget register your github repository into packagist, end user can install your widget only after you complete register. And packagist will give you hint for how to setup service in github to auto synchronize every commit from github to packagist.

Above is my experiences in past 2 days which I success fully create yii2-google-chart extension.

github yii2-google-chart

packagist yii2-google-chart

Total 1 comment

#19939 report it
vishnu_yii at 2016/09/02 07:58am
awesome tutorial

it's nice tutorial

Leave a comment

Please to leave your comment.