I’ve gotten Amazon SDK to work well with Symfony2. It involves loading the sdk.class.php right into the autoload.php. I’m not sure if this is best, but it seems be.
But my main problem is loading the Credentials. Amazon wants you too.. edit the config.inc.php and put it either in the vendor directory OR in the HOME. Option 1 isnt good because it involves modifying a Repo which would get overwritten on updates and HOME doesn’t work because it’s outside my project directory.
What I’m doing now, inside autoload.php is loading the sdk.class.php and then running CFCredentionals:set(array()); .. my code is below. Normally I’d want to do a Dependency Injection or use Parameters.. but I can’t figure out any other way to get the Credentials loaded. Also, I don’t want to load them when I instantiate the Services. like $e3 = new AmazonE3(array($a,$s));. It’s so much cleaner and stream lined to have the credentials pre-loaded so you can just use $e3 = new AmazonE3();
So this is what works — but there’s got to be a better way
require_once __DIR__. '../../vendor/AmazonPHPSDK/sdk.class.php';
CFCredentials::set(array(
'@default' => array(
'key' => '1dfXXXXXXXXXXXXXXXXXXXXXZ82',
'secret' => '8tCXXXXXXXXXXXXXXXXXXXXXXfjB+Q',
'default_cache_config' => 'apc',
'certificate_authority' => false
)));
There’s nothing wrong with how Amazon wants us to load the credentials. It just just doesn’t seem to go well with the Symfony2 framework. Having an Array with Access Credentials in the autoload.php just doesn’t seem right.
Why not use something like the AmazonWebServicesBundle which looks like it allows configuration via
parameters.iniorconfig.yml?The documentation for this is here-link . Currently, the steps to set the credentials via
parameters.iniORconfig.ymlare in step 6 and it looks something like this..