0

I am using filestack api in php. I am trying to make connection with api. I just included its client library file and i am getting an error. Please give me suggestion that which file i have to include for to make connection with Filestack Api. I am including right file? I had downloaded library from github ( https://github.com/filestack/filestack-php/ ). Below the code:

include 'ext-lib/filestack/filestack/FilestackClient.php';
use Filestack\FilestackClient;

Error:

Fatal error: Trait 'Filestack\Mixins\CommonMixin' not found in C:*****************\filestack\FilestackClient.php on line 1

enter image description here

wscourge
  • 10,657
  • 14
  • 59
  • 80
Navdeep
  • 11
  • 1
  • 4
  • This may mean that the path to the file does not match the PSR-4 convention, while still being in the folder (meaning that the classmap generator finds the class when building the optimized autoloader, even if it does not actually respect psr-4). Can you paste the path to the file in which the trait is defined ? – Dipak Jan 20 '18 at 06:42
  • There may be a typo mistake – Dipak Jan 20 '18 at 06:43
  • 'filestack/mixins/CommonMixin.php' in this file trait CommonMixin is definded. – Navdeep Jan 20 '18 at 11:02

1 Answers1

1

Sorry, you should use composer to install this package to your project, as it'll download all the needed dependencies.

Technically, you can manually include the Filestack library using the spl_autoload_register function like so:

<?php
function my_autoloader($class) {
    include 'ext-lib\' . $class . '.php';
}

spl_autoload_register('my_autoloader');

use Filestack\FilestackClient;
$client = new FilestackClient($test_api_key);

But, even though this will resolve all your Filestack paths, it'll still not work because the Filestack SDK has a dependency on GuzzleHttp, so you'll have to manually install that as well. Unfortunately, there is no easy way to manually install GuzzleHttp.

===========

If you really can't use composer, I've created an example project with all the vendor dependencies downloaded. Just make sure you include the vendor/autoload.php file wherever you need to call Filestack objects.

<?php
require __DIR__ . '/vendor/autoload.php';

https://www.dropbox.com/s/7iwritw0pcstwjb/filestack-phptest.zip

Huey Ly
  • 474
  • 4
  • 6