dqroktbn005028 2014-04-17 04:08
浏览 450
已采纳

如何将第三方类库与Laravel集成,以便自动加载?

I am trying to integrate the Temboo SDK with the Laravel framework so that it autoloads like the rest of the vendors.

The SDK has the following structure:

temboo
    src
        library
            temboo._23andme.php
            temboo._37signals.php
            etc...
        temboo.php

Within the main Temboo file, they have multiple class declarations and each one uses naming such as class Temboo_Session and the classes in the library dir are of the form class _23andMe_Names extends Temboo_Choreography.

The temboo.php class file also includes an autoloader class Temboo_Loader and declaration spl_autoload_register(array('Temboo_Loader', 'autoload'));

This is my first time trying to integrate a non-PSR-0 library, so I am a little lost on this.

Any help would be appreciated.

  • 写回答

1条回答 默认 最新

  • dongliao6777 2014-04-17 14:51
    关注

    You can tell Composer to autoload any (non-PSR) class by adding the base folder to:

    "autoload": {
        "classmap": [
            "app/commands",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php"
        ],
        ....
    

    And you can also autoload autoloaders by adding them to the files section:

    "autoload": {
        "files": [
            "temboo/src/Temboo_Loader.php"
        ],
    ...
    

    After adding those entries, execute

    composer dumpautoload
    

    And check the file vendor/composer/autoload_classmap.php, the available classes must be all listed in it, if one file is not there it will not be autoloaded.

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

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献