Skip to content

Commit 19e4941

Browse files
committed
Porting to Laravel 5.0
1 parent 6594388 commit 19e4941

File tree

12 files changed

+39
-35
lines changed

12 files changed

+39
-35
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Laravel 4.2 Lucene search
1+
Laravel 5 Lucene search
22
==============
33

44
[![Latest Stable Version](https://poser.pugx.org/nqxcode/laravel-lucene-search/v/stable.png)](https://packagist.org/packages/nqxcode/laravel-lucene-search)
@@ -7,7 +7,7 @@ Laravel 4.2 Lucene search
77
[![Build Status](https://travis-ci.org/nqxcode/laravel-lucene-search.svg?branch=master)](https://travis-ci.org/nqxcode/laravel-lucene-search)
88

99

10-
Laravel 4.2 package for full-text search over Eloquent models based on ZendSearch Lucene.
10+
Laravel 5.0 package for full-text search over Eloquent models based on ZendSearch Lucene.
1111

1212
## Installation
1313

@@ -16,7 +16,7 @@ Require this package in your composer.json and run composer update:
1616
```json
1717
{
1818
"require": {
19-
"nqxcode/laravel-lucene-search": "1.*"
19+
"nqxcode/laravel-lucene-search": "2.*"
2020
}
2121
}
2222
```
@@ -41,7 +41,7 @@ If you want to use the facade to search, add this to your facades in `app/config
4141
Publish the config file into your project by running:
4242

4343
```bash
44-
php artisan config:publish nqxcode/laravel-lucene-search
44+
php artisan vendor:publish --provider="Nqxcode\LuceneSearch\ServiceProvider"
4545
```
4646
###Basic
4747
In published config file add descriptions for models which need to be indexed, for example:

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nqxcode/laravel-lucene-search",
3-
"description": "Laravel 4.2 package for full-text search over Eloquent models based on ZendSearch Lucene.",
3+
"description": "Laravel 5 package for full-text search over Eloquent models based on ZendSearch Lucene.",
44
"keywords": ["laravel", "lucene", "zendsearch", "eloquent", "search", "fulltext"],
55
"license": "MIT",
66
"authors": [
@@ -11,14 +11,14 @@
1111
],
1212
"require": {
1313
"php": ">=5.4.0",
14-
"illuminate/support": "4.2.*",
14+
"illuminate/support": "5.0.*",
1515
"nqxcode/zendsearch": "2.*",
1616
"nqxcode/lucene-stemmer-en-ru": "1.*"
1717
},
1818
"require-dev": {
1919
"phpunit/phpunit": "3.7.*",
2020
"mockery/mockery": "0.9.*",
21-
"orchestra/testbench": "2.2.*"
21+
"orchestra/testbench": "3.0.*"
2222
},
2323
"autoload": {
2424
"files": [

src/Nqxcode/LuceneSearch/Console/ClearCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function fire()
1515
$this->output = new NullOutput;
1616
}
1717

18-
if ($result = rmdir_recursive(Config::get('laravel-lucene-search::index.path'))) {
18+
if ($result = rmdir_recursive(Config::get('laravel-lucene-search.index.path'))) {
1919
$this->info('Search index is cleared.');
2020
} else {
2121
$this->comment('There is nothing to clear..');

src/Nqxcode/LuceneSearch/Query/Builder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php namespace Nqxcode\LuceneSearch\Query;
22

33
use Illuminate\Database\Eloquent\Collection;
4+
use Illuminate\Pagination\Paginator;
45
use ZendSearch\Lucene\Search\Query\AbstractQuery;
56
use ZendSearch\Lucene\Search\Query\Boolean as QueryBoolean;
67
use Input;
@@ -107,7 +108,7 @@ public function paginate($perPage = 25, $page = null)
107108

108109
$total = $this->count();
109110

110-
$paginator = App::make('paginator')->make($models, $total, $perPage);
111+
$paginator = new Paginator($models, $total, $perPage);
111112

112113
return $paginator;
113114
}

src/Nqxcode/LuceneSearch/ServiceProvider.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Nqxcode\LuceneSearch\Analyzer\Stopwords\FilterFactory;
66
use Nqxcode\LuceneSearch\Index\Connection;
77
use Nqxcode\LuceneSearch\Model\Config as ModelsConfig;
8-
use Nqxcode\LuceneSearch\Pagination\Factory;
98
use ZendSearch\Lucene\Analysis\Analyzer\Common\Utf8Num\CaseInsensitive;
109

1110
class ServiceProvider extends \Illuminate\Support\ServiceProvider
@@ -25,7 +24,7 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
2524
*/
2625
public function boot()
2726
{
28-
$this->package('nqxcode/laravel-lucene-search');
27+
$this->mergeConfigFrom(__DIR__.'/../../config/config.php', 'laravel-lucene-search');
2928
}
3029

3130
/**
@@ -35,14 +34,18 @@ public function boot()
3534
*/
3635
public function register()
3736
{
37+
$this->publishes([
38+
__DIR__.'/../../config/config.php' => config_path('laravel-lucene-search.php'),
39+
]);
40+
3841
$this->app->bind('Nqxcode\LuceneSearch\Search', function ($app) {
3942
return $app['search'];
4043
});
4144

4245
$this->app->bindShared('search', function ($app) {
4346
return new Search(
44-
$app['search.connection'],
45-
$app['search.models.config']
47+
$app['laravel-lucene-search.connection'],
48+
$app['laravel-lucene-search.models.config']
4649
);
4750
});
4851

@@ -52,26 +55,26 @@ public function register()
5255

5356
$this->app->bind('Nqxcode\LuceneSearch\Analyzer\Config', function () {
5457
return new AnalyzerConfig(
55-
Config::get('laravel-lucene-search::analyzer.filters', []),
56-
Config::get('laravel-lucene-search::analyzer.stopwords', []),
58+
Config::get('laravel-lucene-search.analyzer.filters', []),
59+
Config::get('laravel-lucene-search.analyzer.stopwords', []),
5760
new FilterFactory
5861
);
5962
});
6063

61-
$this->app->bindShared('search.index.path', function () {
62-
return Config::get('laravel-lucene-search::index.path');
64+
$this->app->bindShared('laravel-lucene-search.index.path', function () {
65+
return Config::get('laravel-lucene-search.index.path');
6366
});
6467

65-
$this->app->bindShared('search.connection', function ($app) {
68+
$this->app->bindShared('laravel-lucene-search.connection', function ($app) {
6669
return new Connection(
67-
$app['search.index.path'],
70+
$app['laravel-lucene-search.index.path'],
6871
$app->make('Nqxcode\LuceneSearch\Analyzer\Config')
6972
);
7073
});
7174

72-
$this->app->bindShared('search.models.config', function ($app) {
75+
$this->app->bindShared('laravel-lucene-search.models.config', function ($app) {
7376
return new ModelsConfig(
74-
Config::get('laravel-lucene-search::index.models'),
77+
Config::get('laravel-lucene-search.index.models'),
7578
$app->make('Nqxcode\LuceneSearch\Model\Factory')
7679
);
7780
});

src/config/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
'index' => [
2424

25-
'path' => storage_path() . '/lucene-search/index',
25+
'path' => storage_path('app') . '/lucene-search/index',
2626

2727
'models' => [
2828
// Add models descriptions here.

tests/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ protected function getEnvironmentSetUp($app)
3434
));
3535
}
3636

37-
protected function getPackageProviders()
37+
protected function getPackageProviders($app)
3838
{
3939
return array('Nqxcode\LuceneSearch\ServiceProvider');
4040
}
4141

42-
protected function getPackageAliases()
42+
protected function getPackageAliases($app)
4343
{
4444
return array(
4545
'Search' => 'Nqxcode\LuceneSearch\Facade',

tests/functional/BaseTestCase.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace tests\functional;
33

4+
use Illuminate\Support\Facades\Artisan;
45
use tests\TestCase;
56
use Config;
67

@@ -15,20 +16,18 @@ public function setUp()
1516
parent::setUp();
1617
$this->configure();
1718

18-
$artisan = $this->app->make('artisan');
19-
2019
// Call migrations specific to our tests, e.g. to seed the db.
21-
$artisan->call('migrate', ['--database' => 'testbench', '--path' => '../tests/migrations']);
20+
Artisan::call('migrate', ['--database' => 'testbench', '--path' => '../tests/migrations']);
2221

2322
// Call rebuild search index.
24-
$artisan->call('search:rebuild');
23+
Artisan::call('search:rebuild');
2524
}
2625

2726
protected function configure()
2827
{
29-
Config::set('laravel-lucene-search::index.path', storage_path() . '/lucene-search/index_' . uniqid());
28+
Config::set('laravel-lucene-search.index.path', storage_path('app') . '/lucene-search/index_' . uniqid());
3029
Config::set(
31-
'laravel-lucene-search::index.models',
30+
'laravel-lucene-search.index.models',
3231
[
3332
'tests\models\Product' => [
3433
'fields' => [

tests/functional/FieldsBoostingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected function configure()
1515
parent::configure();
1616

1717
Config::set(
18-
'laravel-lucene-search::index.models',
18+
'laravel-lucene-search.index.models',
1919
[
2020
'tests\models\Product' => [
2121
'fields' => [

tests/functional/ModelBoostingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected function configure()
1515
parent::configure();
1616

1717
Config::set(
18-
'laravel-lucene-search::index.models',
18+
'laravel-lucene-search.index.models',
1919
[
2020
'tests\models\Product' => [
2121
'fields' => [

0 commit comments

Comments
 (0)