2
2
2462015-08-17 17:23:37
Composer
246, 2015-08-17 17:23:37

How to change a method in a library correctly?

Hello
Tell me, please, with a problem: in the project, all libraries are pulled by Composer. In one method of one class of one library, you need to make changes. How to do it right? The option to commit the library to the repo goes against the point of using Composer. Create a new class, inherit from the library and override the desired method in it? Then you will have to redefine even more than a dozen accompanying files of this library, which is not very convenient.
Are there any better options? Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2015-08-17
@alexey-m-ukolov

The most reasonable option in terms of further support is to fork the library and add your own fork as dependencies. If this is a hotfix of some kind of bug, then you can send it to the main turnip and then switch back to it when it is accepted.
Another (crutch) option is to copy the required class to a separate folder, change its behavior, and then write a script that, after composer update and composer install , will replace the file from the library with the modified file. Hooks can be used for this ( Thanks to D' Normalization for the link).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question