dongmu3187 2016-03-28 20:08 采纳率: 0%
浏览 114
已采纳

Keen.io php客户端(未找到类)

I have installed composer on Linux ,So i have edited composer.json as this :

{
    "name": "keen-io/keen-io",
    "description": "A PHP library for reporting events to the Keen IO API",
    "type": "library",
    "license": "MIT",
    "keywords": [
        "keen io",
        "analytics"
    ],
    "support": {
        "chat": "https://www.hipchat.com/gIdidQscL"
    },
    "require": {
        "php":           ">=5.3.3",
        "ext-mcrypt":    "*",
        "guzzle/guzzle": "~3.7"
    },
    "require-dev": {
        "phpunit/phpunit": "~3.7.0"
    },
    "homepage": "http://keen.io",
    "autoload": {
        "psr-4": {
            "KeenIO\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "KeenIO\\Tests\\": "tests/Tests"
        }
    },
    "authors": [
        {
            "name": "Tom Anderson",
            "email": "tom.h.anderson@gmail.com"
        },
        {
            "name": "Keith Kirk",
            "email": "keith@kmfk.io",
            "homepage": "http://kmfk.io"
        },
        {
            "name": "Michaël Gallego",
            "email": "mic.gallego@gmail.com",
            "homepage": "http://michaelgallego.fr"
        }
    ]
}

Then i have type this command $ composer update to update composer.json and generate ./vendor/autoload.php . and the purpose of this JSON is to connect to keen.io to use PHP client .

Then i coded this php script :

<?php


    require_once __DIR__ . '/vendor/autoload.php';
​
    use KeenIO\Client\KeenIOClient;


$client = KeenIOClient::factory([
    'projectId' => $projectId,
    'writeKey'  => $writeKey,
    'readKey'   => $readKey
]);
​
?>

But when i run the script the error is :

Fatal error: Class 'KeenIO\Client\KeenIOClient' not found in /opt/bitnami/apache2/htdocs/sandbox/keen.io/test-keen.php on line 9

--------------------------------------------------------------------------- ** scirpt.php:**

<?php

    //* Composer Directory : /htdocs/sandbox/project/KeenClient-PHP/

    //* Current Directory : ~/htdocs/sandbox/project/KeenClient-     PHP/script.php

    //* File_name : script.php

    require_once __DIR__ .'/vendor/autoload.php';

    use KeenIO\Client\KeenIOClient;


    $client = KeenIOClient::factory([
    'projectId' => "Project_ID",
    'writeKey'  => "Write_Key",
    'readKey'   => "Read_Key"
]);


?>
  • 写回答

1条回答 默认 最新

  • doujinyi1267 2016-03-29 14:24
    关注

    Your composer.json file's project is incorrect. This one is from Keen Library. You need something like this:

    {
        "require": {
            "keen-io/keen-io": "~2.5"
        }
    }
    

    Then execute php composer.phar update and include your's vendor/autoload.php file.

    ------------------------- EDIT -------------------------

    enter image description here

    It works. If you copy your script.php to any folder, you must change require_once path, and also it will work for you (I've run it).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮