2014-07-25 13 views
7

Tôi đang cố gắng sử dụng Guzzle, nhưng tôi nhận được lỗi nghiêm trọng sau đây:Composer autoloader không tải GuzzleHttp ClientInterface

Fatal error: Class 'GuzzleHttp\ClientInterface' not found in /var/www/myapp/vendor/guzzlehttp/guzzle/src/functions.php on line 13

Tôi đang tự động load với nhà soạn nhạc autoloader:

require 'vendor/autoload.php'; 

use Guzzle\Http\Client; 

$client = new Client(); 

$requests = Array(
    $client->createRequest('GET', 'ams1.myapp.com:8080/api/ffmpeg_make_snapshots.php'), 
    $client->createRequest('GET', 'ams2.myapp.com:8080/api/ffmpeg_make_snapshots.php'), 
    $client->createRequest('GET', 'ams3.myapp.com:8080/api/ffmpeg_make_snapshots.php') 
); 

$client->sendAll($requests); 

Điều gì đang xảy ra?

EDIT

composer.json của tôi:

{ 
    "require": { 
     "guzzlehttp/guzzle": "~4" 
    } 
} 

EDIT 2

composer.lock My


{ 
    "_readme": [ 
     "This file locks the dependencies of your project to a known state", 
     "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" 
    ], 
    "hash": "33c003b6e3e2dc0144146f9b652a6719", 
    "packages": [ 
     { 
      "name": "guzzlehttp/guzzle", 
      "version": "4.0.0", 
      "source": { 
       "type": "git", 
       "url": "https://github.com/guzzle/guzzle.git", 
       "reference": "4063f08ca434efac12bf7a3db0d370b1c451345b" 
      }, 
      "dist": { 
       "type": "zip", 
       "url": "https://api.github.com/repos/guzzle/guzzle/zipball/4063f08ca434efac12bf7a3db0d370b1c451345b", 
       "reference": "4063f08ca434efac12bf7a3db0d370b1c451345b", 
       "shasum": "" 
      }, 
      "require": { 
       "guzzlehttp/streams": "1.*", 
       "php": ">=5.4.0" 
      }, 
      "require-dev": { 
       "ext-curl": "*", 
       "phpunit/phpunit": "4.*", 
       "psr/log": "~1" 
      }, 
      "type": "library", 
      "extra": { 
       "branch-alias": { 
        "dev-master": "4.0.x-dev" 
       } 
      }, 
      "autoload": { 
       "psr-4": { 
        "GuzzleHttp\\": "src/" 
       }, 
       "files": [ 
        "src/functions.php" 
       ] 
      }, 
      "notification-url": "https://packagist.org/downloads/", 
      "license": [ 
       "MIT" 
      ], 
      "authors": [ 
       { 
        "name": "Michael Dowling", 
        "email": "[email protected]", 
        "homepage": "https://github.com/mtdowling" 
       } 
      ], 
      "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", 
      "homepage": "http://guzzlephp.org/", 
      "keywords": [ 
       "client", 
       "curl", 
       "framework", 
       "http", 
       "http client", 
       "rest", 
       "web service" 
      ], 
      "time": "2014-03-29 23:11:36" 
     }, 
     { 
      "name": "guzzlehttp/streams", 
      "version": "1.4.0", 
      "source": { 
       "type": "git", 
       "url": "https://github.com/guzzle/streams.git", 
       "reference": "3b761a328e5ed6ed519e960aded95d7acbe77894" 
      }, 
      "dist": { 
       "type": "zip", 
       "url": "https://api.github.com/repos/guzzle/streams/zipball/3b761a328e5ed6ed519e960aded95d7acbe77894", 
       "reference": "3b761a328e5ed6ed519e960aded95d7acbe77894", 
       "shasum": "" 
      }, 
      "require": { 
       "php": ">=5.4.0" 
      }, 
      "require-dev": { 
       "phpunit/phpunit": "~4.0" 
      }, 
      "type": "library", 
      "extra": { 
       "branch-alias": { 
        "dev-master": "1.4.x-dev" 
       } 
      }, 
      "autoload": { 
       "psr-4": { 
        "GuzzleHttp\\Stream\\": "src/" 
       }, 
       "files": [ 
        "src/functions.php" 
       ] 
      }, 
      "notification-url": "https://packagist.org/downloads/", 
      "license": [ 
       "MIT" 
      ], 
      "authors": [ 
       { 
        "name": "Michael Dowling", 
        "email": "[email protected]", 
        "homepage": "https://github.com/mtdowling" 
       } 
      ], 
      "description": "Provides a simple abstraction over streams of data (Guzzle 4+)", 
      "homepage": "http://guzzlephp.org/", 
      "keywords": [ 
       "Guzzle", 
       "stream" 
      ], 
      "time": "2014-07-19 18:43:42" 
     } 
    ], 
    "packages-dev": [], 
    "aliases": [], 
    "minimum-stability": "stable", 
    "stability-flags": [], 
    "platform": [], 
    "platform-dev": [] 
} 

EDIT 3

soạn cấu hình -l đầu ra:


[repositories.packagist.type] composer 
[repositories.packagist.url] https?://packagist.org 
[repositories.packagist.allow_ssl_downgrade] true 
[process-timeout] 300 
[use-include-path] false 
[preferred-install] auto 
[notify-on-install] true 
[github-protocols] [git, https] 
[vendor-dir] vendor 
[bin-dir] {$vendor-dir}/bin (vendor/bin) 
[cache-dir] C:/Users/User/AppData/Local/Composer 
[cache-files-dir] {$cache-dir}/files (C:/Users/User/AppData/Local/Composer/files) 
[cache-repo-dir] {$cache-dir}/repo (C:/Users/User/AppData/Local/Composer/repo) 
[cache-vcs-dir] {$cache-dir}/vcs (C:/Users/User/AppData/Local/Composer/vcs) 
[cache-ttl] 15552000 
[cache-files-ttl] 15552000 
[cache-files-maxsize] 300MiB (314572800) 
[discard-changes] false 
[prepend-autoloader] true 
[github-domains] [github.com] 
[home] C:/Users/User/AppData/Roaming/Compose 
+0

Các không gian tên dường như không khớp. Nó đang cố gắng tải 'GuzzleHttp \ ClientInterface' và nó phải là' Guzzle \ Http \ ClientInterface' –

+0

Có vẻ như một số xung đột với hàm functions.php tìm thấy trong thư mục gốc của Guzzle. – Maykonn

+0

Bạn có thể cung cấp 'composer.json' của mình không? –

Trả lời

12

Không gian tên cho bửa tiệc ăn 4 là GuzzleHttp trong bửa tiệc ăn 3 không gian tên chỉ đơn giản là Guzzle.

Một composer.json của:

{ 
    "require": { 
     "guzzlehttp/guzzle": "~4" 
    } 
} 

nên cho phép bạn chạy một kịch bản php của:

require 'vendor/autoload.php'; 

use GuzzleHttp\Client; 

$client = new Client(); 

$requests = Array(
    $client->createRequest('GET', 'ams1.myapp.com:8080/api/ffmpeg_make_snapshots.php'), 
    $client->createRequest('GET', 'ams2.myapp.com:8080/api/ffmpeg_make_snapshots.php'), 
    $client->createRequest('GET', 'ams3.myapp.com:8080/api/ffmpeg_make_snapshots.php'), 
); 

$client->sendAll($requests); 

Nếu autoloader vẫn thất bại sau khi thay đổi namespace nó có thể là phiên bản của nhà soạn nhạc là đã lỗi thời và không nhận dạng được PSR4 tự động tải. Nếu không có tệp nào trong vendor/composer/autoload_psr4.php, hãy thử thực hiện composer self-update, sau đó là composer dump-autoload để xem sự cố có được giải quyết hay không.

+0

Tôi thay đổi thành '" guzzlehttp/guzzle ":" 4.0 "và chạy' composer install', nhưng lỗi bây giờ là: 'Lỗi nghiêm trọng: Lớp 'GuzzleHttp \ Client'' không tìm thấy. Và sử dụng stmt để 'sử dụng GuzzleHttp \ Client'; – Maykonn

+0

@Maykonn the '~ 4' sẽ đủ để cài đặt bất kỳ thứ gì lớn hơn hoặc bằng phiên bản 4. Bạn có thể cung cấp' composer.lock' của mình không? Các phiên bản bạn nên kéo vào với 'composer.json' sẽ có thể tìm thấy không gian tên' GuzzleHttp'. –

+0

xem EDIT 2, có điều gì sai không? Nó được tạo ra tự động bởi cài đặt nhà soạn nhạc .. – Maykonn

Các vấn đề liên quan