Monday, September 23, 2013

Yii: Install Elastica on Yii

Composer and Packagist

Composer is a brilliant dependency manager for PHP. List your project’s dependencies in a composer.json file and, with a few simple commands, Composer will automatically download your project’s dependencies and setup autoloading for you.
There are already a lot of PHP libraries that are compatible with Composer, ready to be used in your project. These “packages” are listed on Packagist, the official repository for Composer-compatible PHP libraries.

How to Install Composer

You can install Composer locally (in your current working directory; though this is no longer recommended) or globally (e.g. /usr/local/bin). Let’s assume you want to install Composer locally. From your project’s root directory:
curl -s https://getcomposer.org/installer | php
This will download composer.phar (a PHP binary archive). You can run this with php to manage your project dependencies. Please Note: If you pipe downloaded code directly into an interpreter, please read the code online first to confirm it is safe.

Install Elastica Using Composer

1.go to home folder, do 
 
vim composer.json
 
paste in: 
{
    "require": {
        "ruflin/Elastica": "dev-master"
    }
}
 
2. do:
 
composer install 

3. copy everything in to yii lib folder

4. when you want to use Elastica, just do:

require('[your base path]/protected/lib/elastica/autoload.php');

0 comments:

Post a Comment