duancong7358 2014-01-26 16:05
浏览 374
已采纳

使用composer将Fpdf / Fpdi类添加到laravel时出现错误'class not found'

I'm trying to add the following two classes:

https://packagist.org/packages/itbz/fpdi
https://packagist.org/packages/itbz/fpdf

I've included them in my composer.json file:

"require-dev": {
        "itbz/fpdi": "dev-master",
        "itbz/fpdf": "1.7.2"
    }

When I try to reference them in my app/config/app.php file like so:

'providers' => array (
    .....
    'itbz\fpdf',
    'itbz\fpdi',
),

'aliases' => array (
    .....
    'Fpdf'            => 'itbz\fpdf\Facades\Fpdf',
    'Fpdi'            => 'itbz\fpdi\Facades\Fpdi',

),

I get a 'class not found' error when I run composer install for both.

I've done composer update after I've included the require-dev information in composer.json, so I believe the errors are in my referencing of the two classes in app/config/app.php. I don't know how to reference them, so if someone is able to help that would be great.

  • 写回答

1条回答 默认 最新

  • dongpu1879 2014-01-26 16:23
    关注

    Have you done a rebuild of your autoloads?

    composer dump-autoload
    

    After that is done, I believe you should be able to just use the classes without use first.

    EDIT: I don't know these packages but I am not sure they include the Facade classes you mention. Facades are very specific to Laravel 4.

    I believe if you remove the aliases then this should work OK:

    'Fpdf'            => 'itbz\fpdf\Facades\Fpdf',
    'Fpdi'            => 'itbz\fpdi\Facades\Fpdi',
    

    if you want to then use these classes in your app, you would say:

    $fpdi = new \fpdi\FPDI();
    $fpdf = new \fpdf\FPDF();
    

    or something like that.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 优质github账号直接兑换rmb,感兴趣伙伴可以私信
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)