我试图托管我的PHP网页,我在Windows 10上(在2台机器上测试,它工作正常)在Ubuntu机器上,我正在运行Ubuntu 22.04.2 LTS,PHP 8.1在Apache服务器上。错误如下:Fatal error: Uncaught Error: Class 'Aws\\IoTDataPlane\\IoTDataPlaneClient' not found in /home/Dioswilson/testPage/classes/AWSThing.php:32
下面是代码,以防你需要它:
AWSThing.php(cropped)
<?php
namespace classes;
use Aws\Credentials\Credentials;
use Aws\IoTDataPlane\IoTDataPlaneClient;
class AwsThing {
private $thingName;
private $userAccessKeyId;
private $userSecretAccessKey;
private $awsCredentials;
private $shadow;
private $client;
public function __construct($thingName, $userAccessKeyId, $userSecretAccessKey) {
$this->thingName = $thingName;
$this->userAccessKeyId = $userAccessKeyId;
$this->userSecretAccessKey = $userSecretAccessKey;
}
public function getShadow() {
return $this->shadow;
}
public function authenticateAwsUser() {
$this->awsCredentials = new Credentials(
$this->userAccessKeyId,
$this->userSecretAccessKey
);
$this->client = new IoTDataPlaneClient([
'credentials' => $this->awsCredentials,
'region' => 'us-east-1',
'version' => 'latest'
]);
}
//Cropped stuff from class......
}
我从index.php调用它
<?php
session_start();
if (isset($_SESSION["login"]) && $_SESSION["login"]) {
// echo "Hello World";
} else {
header("Location: login/login.php");
}
include "./classes/JardinThing.php";
require './vendor/autoload.php';
use classes\JardinThing;
$logoJardin = new JardinThing("ThingName", "key", "secret"); //Ofc this is censored
//More below, but it breaks here
?>
项目结构(在Windows和Ubuntu上):
testPage
|
|-index.php
|->classes
| |-AWSThing.php
|->vendor
|->aws
|->aws-sdk-php
|->src
|->IotDataPlane
|-IotDataPlane.php
唯一引起我注意的是php给出的路径,其中有“”,但我认为它只是用escpae代码打印“”
1条答案
按热度按时间jchrr9hc1#
我认为你需要添加
use Aws\IotDataPlane\IotDataPlaneClient
而不是use Aws\IoTDataPlane\IoTDataPlaneClient
,然后用应该能解决你的问题。