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).

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

报告相同问题?

悬赏问题

  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图