PHP:autoloadでクラスを読み込めません

composer.jsonで何かやらかしてるか

それとも何か手順が抜けてるかだと思いますが

いくらマニュアルを読み込んでもわかりません…

もしなにかありましたらご指摘お願いします

 

■サーバ環境
PHP Version 7.4.10
FreeBSD 11.2-RELEASE-p14

■PHP-SDK
composerにてインストール済み
(Using version[Redacted]6 for square/square)

■composer.json→install済み
{
"name": "square/square",
"description": "Use Square APIs to manage and run business including payment, customer, product, inventory, and employee management.",
"version": "[Redacted]6",
"type": "library",
"keywords": [
"Square",
"API",
"SDK"
],
"homepage": "https://squareup.com/developers",
"license": "MIT",
"authors": [
{
"name": "Square Developer Platform",
"email": "developers@squareup.com",
"homepage": "https://squareup.com/developers"
}
],
"require": {
"php": ">=7.1",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"apimatic/unirest-php": "^2.0",
"apimatic/jsonmapper": "^2.0.1"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
"phan/phan": "^2.5",
"phpunit/phpunit": "^7.5 || ^8.5"
},
"autoload": {
"psr-4": {
"Square\\": "src/"
}
},
"scripts": {
"test": "phpunit",
"test-coverage": "phpunit --coverage-html=coverage",
"lint": "phpcs --standard=phpcs-ruleset.xml src/",
"lint-fix": "phpcbf --standard=phpcs-ruleset.xml src/",
"analyze": "phan --allow-polyfill-parser"
}
}


■テストPHP
↓パス確認済み
require_once('/home/{user}/vendor/autoload.php');

use Square\SquareClient;
use Square\LocationsApi;
use Square\Exceptions\ApiException;
use Square\Http\ApiResponse;
use Square\Models\ListLocationsResponse;
use Square\Environment;

$client = new SquareClient([
'accessToken' => '{アクセストークン]',
'environment' => Environment::SANDBOX,
]);

try {
$locationsApi = $client->getLocationsApi();
$apiResponse = $locationsApi->listLocations();

if ($apiResponse->isSuccess()) {
$listLocationsResponse = $apiResponse->getResult();
$locationsList = $listLocationsResponse->getLocations();
foreach ($locationsList as $location) {
print_r($location);
}
} else {
print_r($apiResponse->getErrors());
}
} catch (ApiException $e) {
print_r("Recieved error while calling Square: " . $e->getMessage());
}


■PHPエラー
Fatal error: Uncaught Error: Class 'Square\SquareClient' not found

1,042件の閲覧回数
メッセージ1/2
不適切なコンテンツを報告
1 返信
Admin

 

@konata29 さん、ご質問ありがとうございます。

 

ComposerをSDKとは違うディレクトリにインストールしている可能性があるようです。 今一度、SDKと同じディレクトリにComposerをインストールしているか、ご確認ください。

 

また、恐れ入りますが、APIに関しては日本のSquareではサポート外となっておりますため、 更に詳しいご質問がある場合は、英語にて開発者サポートへお問い合わせ下さい🙇‍♂

 

✏関連するヘルプセンター記事

SquareでAPIを利用する

開発者用ドキュメント(英語)

間宮 −Mamiya
Square コミュニティ管理者
解決策や有用な回答には、ログイン して ベストアンサーとしてマークをクリックしましょう!
1,030件の閲覧回数
メッセージ2/2
不適切なコンテンツを報告