Skip to content

Commit

Permalink
Initialize elasticsearch (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
cachan committed Nov 22, 2015
1 parent 4665306 commit 69de900
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

ES_HOST=localhost
ES_INDEX=dino
6 changes: 6 additions & 0 deletions app/Http/Controllers/Api/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Search\Search;

class SearchController extends Controller
{

public function __construct(Search $search)
{
var_dump($search);
}
/**
* Display a listing of the resource.
*
Expand Down
31 changes: 31 additions & 0 deletions app/Providers/SearchProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use App\Search\Search;

class SearchProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}

/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->bind('App\Search\Search', function() {
return new Search();
});
}
}
21 changes: 21 additions & 0 deletions app/Search/Search.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Created by PhpStorm.
* User: cc
* Date: 11/22/15
* Time: 1:36 AM
*/

namespace App\Search;


use Elasticsearch\ClientBuilder;

class Search
{

public function __construct()
{
$client = ClientBuilder::create()->setHosts([env('ES_HOST')])->build();
}
}
1 change: 1 addition & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\SearchProvider::class,

],

Expand Down

0 comments on commit 69de900

Please sign in to comment.