I’m trying to use the https://github.com/webonyx/graphql-php/ library to make graphql requests..
But for some reason it doesn’t work, and I can’t figure out why.
I’m using this command to install:
composer require webonyx/graphql-php
Vendor folder with content + composer.json / composer.lock appears in the project folder.
When I try a simple code like:
<?php
require_once 'vendor/autoload.php';
use GraphQLClient;
use GraphQLQuery;
// Replace with your actual GraphQL endpoint and API key
$graphqlEndpoint = 'https://platformurl';
// Set up the GraphQL client
$client = new Client($graphqlEndpoint);
?>
Fatal error: Uncaught Error: Class "GraphQLClient" not found in
/url/test.php:14 Stack trace: #0 {main} thrown in /url/test.php on
line 14
When I check composer.json it contains this:
{
"require": {
"webonyx/graphql-php": "^15.7"
}
}
I tried composer install / update..
I tried a require with the direct link to graphql folder.
But there is no difference.
I found that there was no src/client.php file in the graphql-php library folder but I don’t know if this is necessary or how that comes (chatGPT said this is the reason why it doesn’t works)..
PHP Version is PHP 8+. What could be the reason?