Composer - 无法自动加载文件

时间:2016-10-11 15:59:07

标签: php github composer-php codeigniter-3

我在GitHub上有一个简单的作曲家项目,其目录结构为:

/--
  -composer.json
  -lib/ComposerTest.php

ComposerTest.php文件作为:

namespace lib;

class ComposerTest{

    public function doTest(){
        return "This class was loaded from Composer\n";
    }
}

composer.json as:

{
   "name":"sc/composerTest",
   "autoload":{
       "psr-0":{
           "lib":"./"
              }
        }

  }

使用以下composer.json文件,我可以将GitHub项目包含到我的vendor文件夹中,但无法将其自动加载。

{
   "description" : "The CodeIgniter Application with Composer",
       "require": {
            "php": ">=5.3.2",
             "codeigniter/framework": "3.1.*",
             "kriswallsmith/buzz":"*",
             "maltyxx/bower": "^1.0",
             "sc/composerTest":"dev-master"
        },
         "require-dev": {
             "mikey179/vfsStream": "1.1.*"
        },
         "repositories": [
               {
                 "type": "git",
                  "url": "https://github.com/sc/composerTest.git"
               }
           ]
       }

有人可以提供建议吗?

修改: ComposerTest控制器

class ComposerTest extends CI_Controller
{
    public function index()
    {
       $composerTest = new ComposerTest();
       echo $composerTest->doTest();
     }
 }

0 个答案:

没有答案