I am using an application that I downloaded using Composer.
The package has many classes that can be called and utilized. However, when I run the below code, I am getting the following error.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
include 'vendor/autoload.php';
$clarifai = new \DarrynTen\Clarifai\Clarifai('CLARIFAI_API_KEY');
$input = new Input();
$input->setImage('https://samples.clarifai.com/metro-north.jpg')->isUrl();
$inputResult = $clarifai->getInputRepository()->add($input);
echo json_encode($inputResult);
?>
Error:
Warning: include(/var/www/html/vendor/darrynten/clarifai-php/src/Entity): failed to open stream: Not a directory in /var/www/html/ctest.php on line 7
Warning: include(): Failed opening '/var/www/html/vendor/darrynten/clarifai-php/src/Entity' for inclusion (include_path='.:/usr/share/php') in /var/www/html/ctest.php on line 7
Fatal error: Uncaught Error: Class 'Input' not found in /var/www/html/ctest.php:11 Stack trace: #0 {main} thrown in /var/www/html/ctest.php on line 11
The class Input is located at /var/www/html/vendor/darrynten/clarifai-php/src/Entity
which I am including using the include keyword in PHP right after the first include, of no avail.
include 'vendor/autoload.php';
include '/var/www/html/vendor/darrynten/clarifai-php/src/Entity';
Later, I used the following code
$concept = new \DarrynTen\Clarifai\Entity\Concept();
$concept->setId('boscoe')->setValue(true);
$input = new \DarrynTen\Clarifai\Entity\Input();
$input->setImage('https://samples.clarifai.com/puppy.jpeg')->isUrl()
->setConcepts([$concept]);
$inputResult = $clarifai->getInputRepository()->add($input);
on the last line, I am getting this error. (Guzzle related)
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error:
POST https://api.clarifai.com/v2/inputs
resulted in a400 Bad Request
response: {"status":{"code":10020,"description":"Failure"},"inputs":[{"id":"e25be6bf0a4a4090a774694c016202cb","data":{"image":{"ur (truncated...) in /var/www/html/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111 Stack trace: #0 /var/www/html/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1
Is this also name space related?
include
to specify a whole directory either. – ADysoninclude '/var/www/html/vendor/darrynten/clarifai-php/src/Entity';
- what's this? You're using an autoloader, but you're including a directory. It looks like you mixed up what namespaces do and how autoloading works. – Mjhdarrynten/clarafai-php
package classes, right? – Mjh$clarafai = new DarrynTen\Clarifai\Clarafai;
-> open theClarafai.php
and look fornamespace
keyword. When you specify this namespace, autoloader calculates where it is and includes the file(s) for you. – Mjh