2016-07-13 1 views
0

ich diese Bibliothek von Github installiert haben:Laravel 5: Bibliothek-Klasse nicht gefunden

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

ich die Dateien unter public/term-extractor platziert.

Ich habe versucht, eine Route zu erstellen, um die Ergebnisse der Bibliothek zu testen, aber ich bekomme immer den Fehler Class 'TermExtractor' not found. Hier

ist die Route:

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"; 
    } 
}); 

Was ist los?

+0

Haben Sie setzen Alias ​​und Anbieter in 'app.php' verwenden kann? – KuKeC

+0

@KuKeC Was genau würde ich dort hinstellen? – user6525541

Antwort

0

Zuerst Sie in Ihrem composer.json dependecy für das TermExtractor

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

Innen Datei setzen sollte app.php Sie 2 Dinge tun müssen (so etwas, weiß nicht den richtigen Namen von Alias ​​und Provider (unbedingt composer update tun bevor es)

Erstes Add-Anbieter

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

Zweite hinzufügen ali tun als

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

dass sollten Sie alias geben TermExtractor, die u in ganze app ohne jedes Mal tun require public_path() . '/term-extractor/src/TermExtractor/TermExtractor.php';

Hoffe, es hilft

+0

Wenn ich "Composer Update" mache, bekomme ich dieses Problem: http://i.imgur.com/hrvRPLJ.png – user6525541

+0

Dann entfernen Sie es aus composer.json und fügen Sie es manuell mit Hilfe von [this] (http: // blog.jambura.com/2014/04/26/add-your-own-github-library-in-laravel-using-composer/) – KuKeC

+0

Wie finde ich den Namen des Alias ​​und Providers? – user6525541