2016-07-13 2 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 dependecyに入れなければならない(composer updateを行うようにしてくださいそれを行う前に)

第一、第二は、アリを追加

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

プロバイダを追加

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

としてそれはあなたuはrequire public_path() . '/term-extractor/src/TermExtractor/TermExtractor.php';

はそれが

+0

「composer update」を実行すると、この問題が発生します。http://j.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