Issue
I am working on a project which requires many edits to be made on the required packages. Everything works just fine until an update comes on the horizon. Once a package gets updated, all made changes on it are instantly replaced with the newer version(even there is no actual update on the updated file).
My question is, how can I keep my edits over the modified packages and still be able to run composer update without the fear of losing my edits and starting all over again.
Solution
Short answer: You can't. The update will always pull the code as it exists in the repository and overwrite the local copy. That's how packages work.
Longer answer: You can't. Editing packages is a bad idea. If you find you need to edit the package you are implementing it wrong as there should be no need to modify that code. If you need additional functionality you can:
- Add a wrapper. Create a class, called a facade, that implements that package but with the changed functionality you desire.
- Fork it and add new functionality and see if it can be added to the package. The functionality you desire may be useful to others and could be merged into the package if the author agrees. Then it will exist for all of your future updates.
- Fork it, make your changes, and include that. If for some reason the first two options don't work you can make your own fork of the project and put your changes there. Then whenever you need to update the package to get the latest code you can create a new fork and migrate/merge your changes to it.
Answered By - John Conde
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.