Revision #3 has been created by jwerner on Mar 19, 2019, 11:55:33 AM with the memo:
Fixed some code formatting
« previous (#2)
Changes
Title
unchanged
How to create yii2 extension and push to github and register into packagist to allow end user install from composer
Category
unchanged
How-tos
Yii version
changed
2.0
Tags
changed
yii2, How to, Egoogle,extension, Ggithub, Packagist, Composer, hzl, composer,yii2,Hzl,Packagist,scotthuangzl, google
Content
changed
**1. Create Extension in yii2.**
As for this step, you can refer to [Create Extension](https://github.com/yiisoft/yii2/blob/master/docs/guide/structure-extensions.md "create extension")
In short, you can use gii to create extension after read above article. Just be care to change the output as
```php
@app/vendor/yourname
```
change the namespace as
```php
yourname\yourwidgetname\
```[...]
You can link your github account now.
~~~
```bash
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
~~~```
And then add files.
~~~
```bash
git add <file1>
git add <file2>
git status
git commit -m "your comment"
~~~```
Remote github.
~~~
```bash
$ 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.[...]
After that
~~~
```bash
$ git remote add origin git@github.com:youraccount/yourrepository.git
$ git push -u origin master
i```
It will need input your github account and pass since use -u
.
In future, you only need below
```bash
$ 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.[...]