forked from subchild/CloudFront-PHP-Invalidator
-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.php
36 lines (28 loc) · 876 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?
// add the following action to your controller
public function sampleAction () {
// your AWS credentials
$accessKey = '';
$secretKey = '';
$distributionId = '';
// create cloudfront object
$cloudFront = new favo_Service_Amazon_CloudFront($accessKey, $secretKey);
$cloudFront->setId($distributionId);
// set logger if you want detailed logging
$logger = new Zend_Log();
$writer = new Zend_Log_Writer_Stream('php://output');
$logger->addWriter ($writer);
$cloudFront->setLogger($logger);
// define files to invalidate
$files = array ( 'sample.jpg', 'cache.jpg', 'dummy.txt' );
// invalidate them
if ( $cloudFront->invalidate ($files) ) {
// success
}
else {
// failure
}
// disable view rendering for this example
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
}