You are viewing revision #13 of this wiki article.
This is the latest version of this article.
You may want to see the changes made in this revision.
So you want to use a fork of any existing vendor extension with your Yii 2 install and use the fork, instead of original source. This does not need you to push any update or register your package on packagist.org. You are recommended to follow the approach below:
Step 1 ¶
Let's take an example. Let's say you want to fork the package kartik-v/yii2-widgets
.
Step 2 ¶
Fork the library on GitHub. It is important for you to check if the source contains a valid composer.json
file. This is important for the rest of the steps to work. After the fork, let's say your forked package version is now at https://github.com/yourname/yii2-widgets
. As a next step, you must create a custom branch (you will update the version constraint in composer.json
later to point to your custom branch). Your custom branch name must be prefixed with dev-
. For example, let us assume you create a branch named custom
and your patched updates will be within a branch named dev-custom
.
Step 3 ¶
Push your library changes to the custom branch above (You can check which one it is on Packagist, under “Source:” – Example).
Step 4 ¶
Override your composer.json
in your Yii2 applications root folder to point to your fork repository. The original composer.json
before would have something like below:
"require": {
"kartik-v/yii2-widgets": "*"
},
The composer.json
after edit will need to have these additional lines. Note that the dev-custom
branch named above is used in the require
section as shown below.
{
"repositories":
[
{
"type": "vcs",
"url": "https://github.com/yourname/yii2-widgets"
}
],
"require": {
"kartik-v/yii2-widgets": "dev-custom"
},
}
Step 5 ¶
Now run the following command from console in your application root.
php composer.phar update
Composer should tell you that files have been modified. Answer 'yes' to any questions. This should enable to use your own fork.
permit to integrate yii2 heart
I permit to integrate your amazing extension (grid and widget) with my extension .. yii2-heart
dev-
https://getcomposer.org/doc/05-repositories.md#vcs
You need to rename you own branch with dev- suffix
Not working
I can't manage to make it work. Do you change the require with your name or it remains as it was, changing just the "*" by "dev-custom"? Already tried both, with no success, it says:
"The requested package could not be found in any version" when I put my name, and "The requested package synatree/yii2-dynamic-relations dev-custom could not be found" when I keep the initial user repository.
Any clue?
Your branch name must by
custom
, notdev-custom
. But version is correct"kartik-v/yii2-widgets": "dev-custom"
.If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.