【问题标题】:Autoloading 3rd party composer packages into Laravel 5 Application将 3rd 方作曲家包自动加载到 Laravel 5 应用程序中
【发布时间】:2023-04-10 04:25:01
【问题描述】:

我正在尝试了解 Composer。我想将此包集成到我的应用程序中:https://github.com/thiagoalessio/tesseract-ocr-for-php

到目前为止,我已经完成了以下工作:

composer require thiagoalessio/tesseract_ocr 
composer dump-autoload

我已经在 Controller 方法中使用了这个库:

$tesseract = new TesseractOCR($url);

但我越来越害怕了:

Class 'App\Http\Controllers\TesseractOCR' not found

如何确保 Composer 自动加载包并且它在整个应用程序中可用,以便在控制器中使用?

对不起,这里是 Composer 的新手..

【问题讨论】:

    标签: php laravel laravel-5 composer-php


    【解决方案1】:

    Composer 已经自动加载了包,你只是错误地引用了类名。

    TesseractOCR 位于“全局”命名空间中,因此您需要导入它:

    use TesseractOCR;
    

    然后您可以照常在控制器等中使用它。

    【讨论】:

      猜你喜欢
      • 2015-05-29
      • 2016-05-26
      • 2020-06-24
      • 2018-06-15
      • 2014-08-16
      • 1970-01-01
      • 2013-12-09
      • 2017-12-28
      相关资源
      最近更新 更多