salesforce-marketingcloud / FuelSDK-PHP

FuelSDK-PHP
MIT License
134 stars 142 forks source link

[BUG] config.php file is already present in my project #153

Open Sokulev opened 5 years ago

Sokulev commented 5 years ago

Describe the bug I'm using Magento. config.php file is already present in my project in root dir. I don't want / can't alter it class ET_Client is trying to load it first to get settings instead of using $params when class instantiated.

Causing error: Uncaught exception 'Exception' with message 'baseUrl is null: Must be provided in config file when instantiating ET_Client' in /src/LittlePassports/lpmage/vendor/salesforce-mc/fuel-sdk-php/src/ET_Client.php on line 131

To Reproduce Have empty config.php file in your app root folder.

Expected behavior ET_Client should use params supplied during instantiation or / and config file should be named differently than config.php.

Environment

The bug has the severity

alessandrofilira commented 5 years ago

I've same problem with a Symfony application, any news? Thanks.

garek007 commented 4 years ago

You can move or create your own class for the config.php code. it doesn't have to live in the root.

aalwash commented 4 years ago

Seriously, how difficult is it to add an extra optional parameter in the ET_Client constructor to avoid reading config.php?

function __construct($getWSDL = false, $debug = false, $params = null) 
    {

to

function __construct($getWSDL = false, $debug = false, $params = null, $readConfig = true) {

    //....
    if($readConfig && file_exists(realpath('config.php'))) {

    }

    // ...
}

That simple :)

aalwash commented 4 years ago

There you go a PR ;)

sp72 commented 4 years ago

It's ugly but it works...

$bak = getcwd();
chdir('/where/there/is/no/config.php/file...');
$client = new ET_Client(false, false, $params);
chdir($bak);

I hope it will be fixed soon !

Other solution : Instead of searching the config.php first, read the $params. If empty, search for the file, no constructor modification.