Created
August 10, 2017 08:32
-
-
Save manishkpr/57032da5a2230e91af0a9d8da5d259ba to your computer and use it in GitHub Desktop.
Hang the Amazon AWS SDK in Phalcon PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWS SDK uses a lot of third-party libraries and Framework, so the namespace to manually handle the words will be more trouble, I suggest using Composer to deal with these things, it uses spl_autoload to deal with, so the class will be used in the time to load, Fast and concise. | |
Under the project put composer.json, the content is | |
{ | |
"require": { | |
"aws/aws-sdk-php": "dev-master" | |
} | |
} | |
Download composer.phar placed under the project | |
wget http://getcomposer.org/composer.phar | |
Install the AWS SDK, he will be in the project under a vendor directory, and AWS and dependencies will be placed here | |
php composer.phar install | |
Modify public / index.php, plus program segments | |
require __DIR__ . '/../vendor/autoload.php'; | |
All the way to the side, generally on the end, and then you can add a profile, you can use the project can be used directly | |
After Amazon applies for KEY, edit app / config / config.php plus | |
'aws' => array( 'key' => 'XXXXXXXXX', 'secret' => 'YYYYYYYYY', ), | |
I use the Amazon SES service to a simple test, I will SES made a service, so that we can access directly in other programs | |
編輯 app/config/service.php | |
$di->set('AWSSES', function() use ($config) { | |
$SES = Aws\Ses\SesClient::factory(array( | |
'key' => $config->aws->key, | |
'secret'=> $config->aws->secret, | |
'region'=> 'us-east-1', | |
)); | |
return $SES; | |
}); | |
We can use the SES service directly in the Controller | |
$client = $this->di->get('AWSSES'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment