duandong1869 2015-05-04 13:49
浏览 169
已采纳

使用composer加载git repo - 自动加载问题

I have a github repository https://github.com/KoulSlou/UPS and I would like to add it to my project.

In project root I created composer.json file and defined the following autoloading properties:

{
    "autoload": {
        "files": [
            "libraries/Ups/Ups.php",
            "libraries/Ups/Ups_Base.php",
            "libraries/Ups/Ups_Base_Response.php",
            "libraries/Ups/Ups_Live_Rates.php"
        ]
    }
}

When I run

php composer.phar install 

repository is being downloaded, but it looks like autoloader is not working. When I try to initialize one of the classes

$test = new Ups()

I got the following error:

Fatal error: Class 'Ups' not found in application/....

Did I define "autoload" property incorrectly?

  • 写回答

2条回答 默认 最新

  • dongmale0656 2015-05-20 20:52
    关注

    Finaly, I have found out what was the problem. composer.json file in the project I was trying to load - UPS library -was invalid. I was able to download files when I ran:

    composer.phar install
    

    but it looks like composer.json file was ignored. I found it out when I ran

    composer.phar update
    

    and got

    No valid composer.json was found
    

    With option -v I got error that "name" is undefined index. So, I simply added "name" field to the composer.json. Final version is:

    {
        "name":"KoulSlou/UPS",
        "autoload": {
            "files": [
                "libraries/Ups/Ups.php",
                "libraries/Ups/Ups_Base.php",
                "libraries/Ups/Ups_Base_Response.php",
                "libraries/Ups/Ups_Live_Rates.php"
             ]
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 来个会搭建付费网站的有偿
  • ¥100 有能够实现人机模式的c/c++代码,有图片背景等,能够直接进行游戏
  • ¥20 校园网认证openwrt插件
  • ¥15 以AT89C51单片机芯片为核心来制作一个简易计算器,外部由4*4矩阵键盘和一个LCD1602字符型液晶显示屏构成,内部由一块AT89C51单片机构成,通过软件编程可实现简单加减乘除。
  • ¥15 求GCMS辅导数据分析
  • ¥30 SD中的一段Unet下采样代码其中的resnet是谁跟谁进行残差连接
  • ¥15 Unet采样阶段的res_samples问题
  • ¥60 Python+pygame坦克大战游戏开发实验报告
  • ¥15 R语言regionNames()和demomap()无法选中中文地区的问题
  • ¥15 Open GL ES 的使用
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部