我将Keen包含在我的产品中(下面的代码段)

    require INCLUDE_DIR . '/vendor/autoload.php';   // Autoloader for Composer (https://getcomposer.org/)
    use KeenIO\Client\KeenIOClient;

    class Statistics extends Model {

        private $client;

        public function __construct( $id = null ){
            parent::__construct();
            $this->client = KeenIOClient::factory([
                'projectId' => KEEN_PROJECT_ID,
                'writeKey'  => KEEN_WRITE_KEY,
                'readKey'   => KEEN_READ_KEY
            ]);
        }
...


但是当“ KeenIOClient :: factory”行运行时,我仍然收到“找不到类'KeenIO \ Client \ KeenIOClient'”错误。我能够通过Composer成功安装Keen.io-我觉得这很简单,我很想念-有什么想法吗?

最佳答案

因此,我不能发表评论,但我想知道包含路径是否存在问题?我能够使此PHP代码段正常工作:

require 'vendor/autoload.php';
use KeenIO\Client\KeenIOClient;

$client = KeenIOClient::factory([
  'projectId' => "53f3a8687d8cb95095000001",
  'readKey' => "99a06e48fd7fb1279bc40995160eb0b61a9e0efaab8b651b029f0d895f77c0a804ba089282eff28bf8ad07f337422441d0542b7feaac9fea1e92fc153ee7efc51afad3276bda8d7754a338b349d540bfb402cba0dfdc82498c217054efd8abd0f47a0c0bc963bbdf0dc938c91b17d9f2"
]);

$count = $client->count('bitcoin-prices', [
  'impressions' => [
    'interval' => 'daily',
    'timeframe' => 'this_30_days',
    'group_by' => 'keen.timestamp'
  ]
]);

print_r($count);


该项目ID和读取密钥来自敏锐的io开放数据集(可用于测试)。

关于keen-io - 找不到类“KeenIO\Client\KeenIOClient”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26985558/

10-13 00:33