2016-03-28 11 views
0

(sınıf bulunamadı), Yani ben bu kadar composer.json düzenledikten: Bu komut $ composer updatebesteciyi güncellemek içinKeen.io php istemci Linux üzerinde besteci yüklemiş

{ 
    "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": "[email protected]" 
     }, 
     { 
      "name": "Keith Kirk", 
      "email": "[email protected]", 
      "homepage": "http://kmfk.io" 
     }, 
     { 
      "name": "Michaël Gallego", 
      "email": "[email protected]", 
      "homepage": "http://michaelgallego.fr" 
     } 
    ] 
} 

Sonra ben türüne sahip .json ve ./vendor/autoload.php üretir. ve bu JSON'un amacı, PHP istemcisini kullanmak için keen.io'a bağlanmaktır. --------------

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

:

Sonra ben bu php script kodlanmış:

<?php 


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


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

Ama senaryoyu çalıştırdığınızda hatadır -------------------------------------------------- ----------- ** 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" 
]); 


?> 

cevap

1

Composer.json dosyanızın projesi yanlış. Bu Keen Library'den. Böyle bir şey gerekir:

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

Sonra php composer.phar güncellemesini yürütmek ve sizin en satıcı/autoload.php dosyasını içerir.

------------------------- DÜZENLEME -------------------- -----

enter image description here

çalışıyor. Script.php dosyanızı herhangi bir klasöre kopyalarsanız, require_once yolunu değiştirmeniz gerekir ve ayrıca sizin için çalışacaktır (çalıştırıyorum).

+0

Cevabınız için teşekkürler, ama script.php bu direk içine koyduğumda bu ~/htdocs/sandbox/proje/KeenClient-PHP/script.php github'dan aldığım gibi aynı composer.json ile: https : //github.com/keenlabs/KeenClient-PHP. çalıştı ama herhangi bir dir içinde script.php koyduğumda hatalar gösterilir ... – luka

+0

Script.php gösterebilir misiniz? Aynı sınıf bulunamadı hatasıyla çöküyor? –

+0

Script.php'yi orijinal yanıt defterine – luka