[英]Autoloading 3rd party composer packages into Laravel 5 Application
I am trying to get my head around Composer. 我正在努力让Composer着迷。 I want to integrate this package into my app: https://github.com/thiagoalessio/tesseract-ocr-for-php 我想将此软件包集成到我的应用程序中: https : //github.com/thiagoalessio/tesseract-ocr-for-php
I have done the following so far: 到目前为止,我已经完成了以下工作:
composer require thiagoalessio/tesseract_ocr
composer dump-autoload
and I have used the library within a Controller method as such: 我已经在Controller方法中使用了该库,例如:
$tesseract = new TesseractOCR($url);
But I'm getting the dreaded: 但是我感到恐惧:
Class 'App\Http\Controllers\TesseractOCR' not found
How do I make sure that composer autoloads the package and that it is available throughout the apps, for usage within controllers? 如何确保composer自动加载程序包,并且在整个应用程序中都可用,以便在控制器中使用?
Sorry, newbie in Composer here.. 抱歉,这里是Composer的新手。
Composer has auto-loaded the package, you're just referencing the class name incorrectly. Composer 已自动加载了程序包,您只是错误地引用了类名。
TesseractOCR
lives in the “global” namespace, so you need to import it: TesseractOCR
位于“全局”名称空间中,因此您需要导入它:
use TesseractOCR;
You can then use it in your controllers etc as normal. 然后,您可以像平常一样在控制器等中使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.