Composer -- PHP依赖管理的用法
安装es的php客户端autoload
composer的安装

ln -s /usr/local/php/etc/bin/php /usr/bin/php
curl -sS https://getcomposer.org/installer | php
cp composer.phar /usr/bin/composer #就能直全局接用 composer 命令了 

安装es的php客户端autoload
到一个目录下

vim composer.json

写入

{
    "require": {
        "elasticsearch/elasticsearch": "~2.0@beta"
    }
}

运行

php composer.phar install
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 5 installs, 0 updates, 0 removals
  - Installing react/promise (v2.5.1): Downloading (100%)         
  - Installing guzzlehttp/streams (3.0.0): Downloading (100%)         
  - Installing guzzlehttp/ringphp (1.1.0): Downloading (100%)         
  - Installing psr/log (1.0.2): Downloading (100%)         
  - Installing elasticsearch/elasticsearch (v2.3.2): Downloading (100%)         
elasticsearch/elasticsearch suggests installing monolog/monolog (Allows for client-level logging and tracing)
Writing lock file
Generating autoload file

完成后在当前目录下会有
vendor
把vendor重命名为Elasticsearch
放到第三方扩展目录下,比如thinkcmf的simplewindCoreLibraryVendor\
引用 use CommLibElasticsearch
即可用
也可使用如下使用方法

public function es_test(){
    Vendor('Elasticsearch.autoload');
    $params['hosts'] = array(
            '192.168.0.186:9200'
    );
    $this->client = new \Elasticsearch\Client($params);
    print_r($this->client);
}

有时候国外镜像太慢,可用设置其使用国内镜像。
比如安装七牛
这样即可直接用命令,无需加 php composer.part xxx了

mv composer.phar /usr/bin/composer
composer config -g repo.packagist composer https://packagist.phpcomposer.co
composer require qiniu/php-sdk
Your version of PHP, 5.4.1, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^7.2 for qiniu/php-sdk
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing qiniu/php-sdk (v7.2.3): Downloading (100%)         
Writing lock file
Generating autoload files