Composer的自动加载没有类映射

时间:2013-06-21 09:26:19

标签: php composer-php

我正在加载这个回购:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "ivantcholakov/gibberish-aes-php",
                "version": "master",
                "source": {
                    "url": "https://github.com/ivantcholakov/gibberish-aes-php.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    ],
    "require": {
        "ivantcholakov/gibberish-aes-php": "*@dev"
    }
}

但是生成的classmap是空的,我不能使用repo:

<?php

// autoload_classmap.php generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
);

我的composer.json设置有什么问题?

PS:我跑了update

1 个答案:

答案 0 :(得分:5)

您必须为存储库配置自动加载选项,如下所示:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "ivantcholakov/gibberish-aes-php",
                "version": "master",
                "source": {
                    "url": "https://github.com/ivantcholakov/gibberish-aes-php.git",
                    "type": "git",
                    "reference": "master"
                },
                "autoload": {
                    "classmap": ["/"]
                }
            }
        }
    ],
    "require": {
        "ivantcholakov/gibberish-aes-php": "*@dev"
    }
}

正如在社区中看到的那样,有时需要安装新的作曲家。