Laravel composer fork project for urgent own use

Nowadays, we definitely using other people packages in own project. What if you found a bug or special workflow to suit your own need. But the project owner didn’t accept the pull request or them didn’t maintenance the project anymore.

If you brave enough you can fork it and continue maintaining it. So people can continue with your repo.

However, I don’t think it is the common use case. So what should you do? Thank God, it has an easy fix in your composer.

First, you, of course, need to fork the project. Then create a branch name start with dev- ,e.g  dev-fix-something then do whatever you need then commit to your repo.

In you composer.json file. add the follow lines. Can be before require tag:

"repositories": [{
  "type": "vcs",
  "url": "https://github.com/my-name/awesomeproject"
}],

Then in the require tag, u need to change original package repo to your new branch.

"require": {
    "php": ">=7.0.0",
    "pro-developer/awesomeproject": "dev-fix-something",

Save your composer.json file. Then go to Terminal run composer update

Then you should be using your own fix branch. If the repo owner finally accepted your pull request, then you can switch back to the original require version.

Note:

If you somehow run the composer update got error like below:-

Your requirements could not be resolved to an installable set of packages.

Problem 1
The requested package pro-developer/awesomeproject dev-fix-something exists as pro-developer/awesomeproject[0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 1.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.4.1, 1.0.5, 2.0, 2.0.1, 2.0.10, 2.0.12, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 3.0, 3.0.1, 3.0.10, 3.0.11, 3.0.12, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.8, 3.0.9, 3.1, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.2, 3.1.3, 3.1.4, 3.1.4.1, 3.1.6, 3.1.7, 3.1.8, 3.2.0, 3.2.1, 3.2.2, 3.3.0, 3.3.1, 3.3.2, 4.0, 4.0.1, 4.0.10, 4.0.11, 4.0.12, 4.0.2, 4.0.3, 4.0.4, 4.0.5, 4.0.6, 4.0.7, 4.0.8, 4.0.9, 4.1, 4.1.1, 4.1.10, 4.1.11, 4.1.12, 4.1.2, 4.1.23, 4.1.3, 4.1.4, 4.1.5, 4.1.6, 4.1.7, 4.1.8, 4.1.9, 5.0.0, dev-dev-fix-something] but these are rejected by your constraint.

You could be gotten wrong branch name. In the above example the correct name should be dev-dev-fix-something, just make the changes in your composer.json then you can ready to run composer update again. It should be working fine.

After the composer update, you can run composer show -v pro-developer/awesomeproject to see the details. You should be to see the support source is from your own repo.

That’s all. Thanks for reading. Happy Coding! Make more great open source project and contribute more to the community.

open edit from cmd like notepad++, sublime or atom

If you come from Mac or Linux. When you want to edit a program. You can easily use console editor to edit the file.

e.g vi /etc/hosts so you can edit the hosts file.

But how you able to do it in Windows. Previously, I need to go to the Windows Explorer, go to that path and then open notepad drag and drop (If you turn off User Account Control Settings – which is not recommended by Windows). Kind of many step to do…

The easy way to accomplished is using below command. I assumed you had installed notepad++

start notepad++ composer.json

In this way, you able to open the file directly from notepad++ or other editor you like.

Please be reminder you only can do so, if you editor had added into SYSTEM ENVIRONMENT PATH.

Tips: Another good cmd alternative in windows I am using https://conemu.github.io/