How to use composer to replace a class in a third-party package

Source: Internet
Author: User
Foxexample: there is a FlarumCoreUser class in a third-party package. what should I do if I write a FlarumCoreUser class myself and want composer to use the User class I created when auto loading? The method has been found. The namespace is still the class... Fox example:
A third-party package used has Flarum\Core\UserClass
Now I write Flarum\Core\UserClass
I want to use the one I created when composer automatically loads UserClass, what should I do?

The method has been found. The namespace is still the original namespace of the class.composerThe class I wrote will be automatically loaded.

"autoload": {    "classmap": [        "vendor/path/to/src/User.php"    ]},

Reply content:

Fox example:
A third-party package used hasFlarum\Core\UserClass
Now I writeFlarum\Core\UserClass
I want to use the one I created when composer automatically loadsUserClass, what should I do?

The method has been found. The namespace is still the original namespace of the class.composerThe class I wrote will be automatically loaded.

"autoload": {    "classmap": [        "vendor/path/to/src/User.php"    ]},

There is a third-party library that you want to rewrite and load the code you have rewritten?
If your third-party library is hosted on github, you fork the project, clone it to the local device, modify it, push it to github, and thencomposer.jsonReference the address of your fork project.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.