Extend An Existing Extension

I’m using this extension: https://github.com/dektrium/yii2-user

Now I created some files in my own vender/infoweb/yii2-user folder to override some functionality

Next I want to put this on github and packagist so other people can use or expand this

How can I push the infoweb/yii2-user folder to github, not my entire yii2 project?

Next I should just add the compose files, and add it to packagist?

I’m going to try git-subtree

I created a subtree:

https://help.github.com/articles/working-with-subtree-merge

http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/

cd [vendor]

cd [infoweb]

cd [yii2-user]

git init

git add .

git commit -m "Initial commit"

git remote add -f [users] git@github.com:hashie5/yii2-user.git

git merge -s ours --no-commit [users]/master

git read-tree --prefix=/ -u [users]/master

git push [users] master

If the merged repository changes in the future, you can pull in its changes by simply using the -s subtree flag:

git pull -s subtree [users] master

And I added this to packagist:

https://packagist.org/packages/infoweb/yii2-user

Maybe we should add an example like this (or a better one) to the guide?

You can get help from this article I created for using forked repositories with composer.

Hey Kartik

Your article is nicely written and that’s exactly the approach I advise too. Though I’d suggest to replace


composer update

with


composer install

in the last code line of the article. It may save some time to composer newbies from not-needed or unexpected dependencies updates.

I’m not using a fork, it’s my own module wich is an extension for the yii2-user module (or extension, I don’t know the differences between modules and extensions)

Am I doing it wrong and should I just use my own forked extension like you suggest?

Anyway what I did is working now, thanks

Yugene, thanks for the info. The updated article is now here. I am collating all such tips into a searchable site for all. Hope its useful.

Hashie, extension or module is same from composer installation perspective. If its your own module - you can directly put it inside your application folder like in Yii 1.x and use it. But if you want to circulate it or reuse it across multiple installs - you must register it on packagist or your own repository for access through composer.

But if you are using a fork of an extension, the approach as mentioned in this article is recommended, to save all hassles of composer overwriting from the extension source OR you end up registering duplicate extensions on packagist.

Great, these are my 2 extensions:

yii2-user

yii2-pages

Very small, just a start, I’ve never used yii 1

Yes this is very usefull, thanks!

Tony has an interesting blog too

http://www.ramirezcobos.com/

But he stopped writing new articles