2016-07-13 3 views
0

내가 GitHub의에서이 라이브러리를 설치 한 찾을 수 없습니다 Laravel 5 : 도서관 클래스는

https://github.com/robholmes/term-extractor

내가 public/term-extractor에서 파일을 배치.

라이브러리 결과를 테스트하는 경로를 만들려고했지만 오류가 계속 발생합니다. Class 'TermExtractor' not found.

Route::get('/test', function() 
{ 
    require public_path() . '/term-extractor/src/TermExtractor/TermExtractor.php'; 

    $text = 'Inevitably, then, corporations do not restrict themselves merely to the arena of economics. Rather, as John Dewey observed, "politics is the shadow cast on society by big business". Over decades, corporations have worked together to ensure that the choices offered by \'representative democracy\' all represent their greed for maximised profits. This is a sensitive task. We do not live in a totalitarian society - the public potentially has enormous power to interfere. The goal, then, is to persuade the public that corporate-sponsored political choice is meaningful, that it makes a difference. The task of politicians at all points of the supposed \'spectrum\' is to appear passionately principled while participating in what is essentially a charade.'; 

    $extractor = new TermExtractor(); 
    $terms = $extractor->extract($text); 
    // We're outputting results in plain text... 
    header('Content-Type: text/plain; charset=UTF-8'); 
    // Loop through extracted terms and print each term on a new line 
    foreach ($terms as $term_info) { 
     // index 0: term 
     // index 1: number of occurrences in text 
     // index 2: word count 
     list($term, $occurrence, $word_count) = $term_info; 
     echo "$term\n"; 
    } 
}); 

문제점은 무엇입니까 : 여기

는 길입니까?

+0

당신이'app.php'에 별칭 및 제공을 넣어 가지고하는 데 도움이 희망 할 때마다 않고 전체 응용 프로그램에서 사용할 수있는 별칭 TermExtractor을 제공해야합니까? – KuKeC

+0

@KuKeC 정확히 무엇을 넣을까요? – user6525541

답변

0

먼저 당신이, (이 같은 2 가지를 할 필요가 별명과 공급자의 적절한 이름을 몰라 app.php 파일 내부에서 그 TermExtractor

"require": { 
"robholmes/term-extractor" : "3.*" 
} 

에 대한 귀하의 composer.json 실행 종속에 넣어해야합니다 (composer update을해야합니다 그것을)하기 전에

먼저 추가 제공

'providers' => [ 
term-extractor/TermExtractorProvider::class 
] 

둘째 알리 추가

'aliases' => [ 
'TermExtractor' => term-extractor\TermExtractor\Facades\TermExtractor::class, 
] 

으로 그것은 당신에게 유 require public_path() . '/term-extractor/src/TermExtractor/TermExtractor.php';

그것이

+0

'composer update'를 할 때,이 문제가 발생합니다 : http://i.imgur.com/hrvRPLJ.png – user6525541

+0

그런 다음 composer.json에서 제거하고 [this] (http : //)의 도움으로 수동으로 추가하십시오 blog.jambura.com/2014/04/26/add-your-own-github-library-in-laravel-using-composer/) – KuKeC

+0

별칭과 공급자의 이름을 어떻게 찾을 수 있습니까? – user6525541