Overload symfony2 vendor class to set curl verify_peer option to false

前提是你 提交于 2019-12-11 11:18:12

问题


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:


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]]


来源:https://stackoverflow.com/questions/28941061/overload-symfony2-vendor-class-to-set-curl-verify-peer-option-to-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!