0
votes

I am trying to send a text message using the Composer AWS SDK on PHP.

PHP 7.2.11 (cli) (built: Oct 10 2018 02:39:52) ( ZTS MSVC15 (Visual C++ 2017) x8 6 ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.11, Copyright (c) 1999-2018, by Zend Technologies

Got composer installed and installed the aws-sdk-php. Now when i run it, i literally get the infamous error Class 'Aws\Sns\SnsClient' not found. I have tried all sorts of code samples including the one on the AWS sample documentation page. I do confirm that i have re-run composer require aws/aws-sdk-php just to be doubly sure. Here's the output:

Using version ^3.145 for aws/aws-sdk-php ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Writing lock file Generating autoload files

This leads me to believe that the sdk itself seems to be missing or for some reasons the autoload.php is unable to find it. Help anyone, must be a simple config that i am not seeing.

PHP Code:

  *<?php
  require 'E:\Bitnami\apps\phpmyadmin\htdocs\vendor\autoload.php';
 $params = array(
   'credentials' => array(
    'key' => 'XXXX',
    'secret' => 'XXXX',
    ),
   'region' => 'us-east-1', // < your aws from SNS Topic region
   'version' => 'latest'
  );
  $sns = new \Aws\Sns\SnsClient($params);*

Regards,

Ochen

1
Can you check in the vendor directory the AWS SDK was correctly pulled in?Chris Williams
oh yeah, i forgot to mention, i don't see the aws sdk file....Ochen Ao
Did you run it in the E:\Bitnami\apps\phpmyadmin\htdocs directory?Chris Williams
Bingo spot on... mate !!! I didn't. Ok, i either have to run it again in the direcotryy or copy it from the earlier location.....Ochen Ao
Run it in the directory, do not copy as this will not add it to the composer.lock :)Chris Williams

1 Answers

1
votes

As the file is not in that vendor folder ensure the following:

  • Write permissions exist for E:\Bitnami\apps\phpmyadmin\htdocs and its subfolders
  • Run composer install (or require) in E:\Bitnami\apps\phpmyadmin\htdocs
  • Check the composer.lock file for E:\Bitnami\apps\phpmyadmin\htdocs has the AWS SDK in it.