Home >Backend Development >PHP Tutorial >How to use composer to replace a class in a third-party package
Fox example: A third-party package used by
has a FlarumCoreUser
class
Now I have written a FlarumCoreUser
class
I want composer to use the User
class I created myself when it loads automatically. , how to do it?
I have found a method. The namespace is still the original namespace of that class, so composer
will automatically load the class I wrote
<code class="php">"autoload": { "classmap": [ "vendor/path/to/src/User.php" ] },</code>
Fox example: A third-party package used by
has a FlarumCoreUser
class
Now I have written a FlarumCoreUser
class
I want composer to use the User
class I created myself when it loads automatically. , how to do it?
I have found a method. The namespace is still the original namespace of that class, so composer
will automatically load the class I wrote
<code class="php">"autoload": { "classmap": [ "vendor/path/to/src/User.php" ] },</code>
There is a third-party library. You have to rewrite it and load your rewritten code. What does this mean?
If your third-party library is hosted on github, you fork the project, then clone it locally, and modify it Push to github, and then quote the address of your fork project in composer.json
.