2017 © Pedro Peláez
 

yii2-extension yii2-xmlpipe

Sphinx XmlPipe Extension for Yii 2

image

mongosoft/yii2-xmlpipe

Sphinx XmlPipe Extension for Yii 2

  • Thursday, April 23, 2015
  • by mongosoft
  • Repository
  • 3 Watchers
  • 6 Stars
  • 1,720 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 5 % Grown

The README.md

Sphinx XmlPipe Extension for Yii 2

This extension provides an easy way to create xmlpipe2 data source for the Sphinx search engine., (*1)

Latest Stable Version Total Downloads, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

composer require --prefer-dist mongosoft/yii2-xmlpipe "*"

or add, (*5)

"mongosoft/yii2-xmlpipe": "*"

to the require section of your composer.json file., (*6)

Usage

XmlPipe document

<?php

namespace app\models;

use mongosoft\xmlpipe\BaseXmlPipe;

class XmlPipeDocument extends BaseXmlPipe
{
    /**
     * @inheritdoc
     */
    public function fields()
    {
        return [
            'name',
            'description',
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributes()
    {
        return [
            ['name' => 'type', 'type' => 'int', 'bits' => 16],
            ['name' => 'name', 'type' => 'string'],
            ['name' => 'description', 'type' => 'string'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function addDocuments()
    {
        $query = Items::find()
            ->select(['type', 'full_name', 'description'])
            ->asArray();

        foreach ($query->each() as $item) {
            $this->pushDocument([
                'type' => $item['type'],
                'name' => $item['full_name'],
                'description' => $item['description'],
            ]);
        }
    }
}

Controller

<?php

namespace app\controllers;

use yii\web\Controller;

class TestController extends Controller
{
    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'xmlpipe' => [
                'class' => 'mongosoft\xmlpipe\Action',
                'document' => 'app\models\XmlPipeDocument',
            ],
        ];
    }
}

Sphinx config

Add the following lines to the configuration file (sphinx.conf), (*7)

source myindex
{
    type               = xmlpipe2
    xmlpipe_command    = curl http://localhost/test/xmlpipe
}

index myindex
{
    source             = myindex
    path               = /var/path/to/index/myindex
    docinfo            = extern
    morphology         = lemmatize_ru
    charset_type       = utf-8
}

The Versions

23/04 2015

dev-master

9999999-dev https://github.com/mongosoft/yii2-xmlpipe

Sphinx XmlPipe Extension for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexander Mohorev

extension yii2 sphinx xmlpipe2 xmlpipe xml-pipe

09/04 2015

0.1.1

0.1.1.0 https://github.com/mongosoft/yii2-xmlpipe

Sphinx XmlPipe Extension for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexander Mohorev

extension yii2 sphinx xmlpipe2 xmlpipe xml-pipe

09/04 2015

0.1.0

0.1.0.0 https://github.com/mongosoft/yii2-xmlpipe

Sphinx XmlPipe Extension for Yii 2

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexander Mohorev

extension yii2 sphinx xmlpipe2 xmlpipe xml-pipe