D
D
Dmitry2017-05-30 00:37:04
Laravel
Dmitry, 2017-05-30 00:37:04

How to replace the implementation in a third-party component?

The project uses the gloudemans/shoppingcart package .
There was a need to expand the functionality and the only option is to expand the base "CartItem" object.
What is the smartest way to change the CartItem implementation?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rikcon, 2017-05-30
@another_dream

Fork, do whatever you want, specify a link to your repository in the composer, it will take the package not from the author, but from you.
PROFIT
Example, here is my fork of the package for Laravel https://github.com/Rikcon/recaptcha

"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/Rikcon/recaptcha"
        }
    ]

K
Kamol, 2017-05-30
@H_Kamol

You can also do this:
1. Extend the vendor class. Create a class App\CartItem extends Gloudemans\Shoppingcart\CartItem
2. Override the desired method in the generated class.
3. Use your generated/extended class in the right places.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question