DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

ApiGatewayManagementApi: syntax error, unexpected '?', expecting variable for guzzlehttp

Why I am unable to send data from my backend to the websocket?

I made a simple php example that sends data to all api gateway clients:

<?php
// Representing an existing php application
require(__DIR__.'/vendor/autoload.php');
$config=require(__DIR__.'/config.php');

use Aws\ApiGatewayManagementApi\ApiGatewayManagementApiClient;

$item     =  $_POST['order_item'];
$quantity =  $_POST['quantity'];

echo "$quantity X $item";
// Replace with host

$dsn = "mysql:host={$config['database']['host']};dbname={$config['database']['name']}";

$options = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE =>

I get the following error:

<b>Parse error</b>:  syntax error, unexpected '?', expecting variable (T_VARIABLE) in <b>/var/www/html/vendor/guzzlehttp/guzzle/src/ClientInterface.php</b> on line <b>81</b><br />

Once I try to initialize an ApiGateWayManagementApi via php aws sdk.

Top comments (1)

Collapse
 
pcmagas profile image
Dimitrios Desyllas

In the end it was just old php version. With php7.2 worked like a charm.