Overload symfony2 vendor class to set curl verify_

2019-08-02 11:59发布

Using the Payum bundle with symfony2, I have the common unable to verify ssl certificate error.

I couldn't get rid of it by changing curl options in php.ini or by setting curl options in my php code.

However, modifying the vendor/kriswallsmith/buzz/lib/Buzz/Client/AbstractClient.php class and setting the default $verifyPeer option to false finally allows me to use Payum and PayPal express checkout locally with wamp.

EDIT: I can also override this class which uses the other one. I feel it's safer:

vendor/payum/core/Payum/Core/Bridge/Buzz/ClientFactory.php

How can I override this class (ideally conditionally ie in dev mode when I'm working locally) ?

1条回答
等我变得足够好
2楼-- · 2019-08-02 12:35

You can overwrite the service payum.buzz.client. Just define it in your bundle which is registered after PayumBundle.

<service id="payum.buzz.client" class="Buzz\Client\ClientInterface"     factory-class="Payum\Core\Bridge\Buzz\ClientFactory" factory- method="createCurl">
        <call method="setVerifyPeer">
            <argument>false</argument>
        </call>
</service>

or in yml

services:
    payum.buzz.client:
        class: Buzz\Client\ClientInterface
        factory_class: Payum\Core\Bridge\Buzz\ClientFactory
        factory_method: createCurl
        calls:
            - [setVerifyPeer, [false]]
查看更多
登录 后发表回答