ThomasJSmart
Programmer
- Sep 16, 2002
- 634
How do i instantiate AWS inside of a class? All the examples seem to be procedural.
For example, i was thinking something like this:
and then i could reference $this->aws throughout the class or extends.
but it is telling me this:
Fatal error: MyLoader cannot use Aws\Common\Aws - it is not a trait in MyLoader.php on line 8
Note: i installed aws using composer as recommended by amazon which generated the autoloader file i am using. I have tried different variations of the above but all with errors.
the error on line 8 is referencing the "use" line.
what is the right way to do this to get it working the way i want?
Thanks!
Thomas
site | / blog |
For example, i was thinking something like this:
Code:
<?PHP
date_default_timezone_set('myTimezone');
// load aws using composer
require_once dirname(__FILE__).'/vendor/autoload.php';
class MyLoader{
use Aws\Common\Aws;
protected $aws = NULL;
public function __construct(){
$this->aws = Aws::factory(array(
'key' => 'mykey',
'secret' => 'mysecret',
'region' => 'myregion'
));
}
}
and then i could reference $this->aws throughout the class or extends.
but it is telling me this:
Fatal error: MyLoader cannot use Aws\Common\Aws - it is not a trait in MyLoader.php on line 8
Note: i installed aws using composer as recommended by amazon which generated the autoloader file i am using. I have tried different variations of the above but all with errors.
the error on line 8 is referencing the "use" line.
what is the right way to do this to get it working the way i want?
Thanks!
Thomas
site | / blog |