创建一个作曲家自定义类

时间:2013-08-04 12:16:53

标签: composer-php

我是作曲家的新手。但我正在尝试创建一个自定义类,在我的项目的根目录而不是供应商目录中安装依赖包。我尝试按照getcomposer.org上的示例进行操作,但我收到以下错误:

PHP Fatal error:  Class 'jeffreycwitt\Composer\LombardPressInstaller' not found in phar:///usr/local/bin/composer/src/Composer/Installer/InstallerInstaller.php on line 100

Fatal error: Class 'jeffreycwitt\Composer\LombardPressInstaller' not found in phar:///usr/local/bin/composer/src/Composer/Installer/InstallerInstaller.php on line 100

下面是我制作的composer.json和自定义类。你能看到任何问题???

composer.json

   {
        "name": "jeffreycwitt/lombardpress-installer",
        "type": "composer-installer",
        "license": "MIT",
        "autoload": {
            "psr-0": {"jeffreycwitt\\Composer": ""}
        },
        "extra": {
            "class": "jeffreycwitt\\Composer\\LombardPressInstaller"
        }
    }

lombardpressInstaller.php

namespace jeffreycwitt\Composer;

use Composer\Package\PackageInterface;
use Composer\Installer\LibraryInstaller;

class LombardPressInstaller extends LibraryInstaller
{
    /**
     * {@inheritDoc}
     */
    public function getInstallPath(PackageInterface $package)
    {
        return '';
    }

    /**
     * {@inheritDoc}
     */
    public function supports($packageType)
    {
        return 'jeffreycwitt-lombardpress' === $packageType;
    }
}

1 个答案:

答案 0 :(得分:1)

我的自动加载部分如下所示:

"autoload": {
    "psr-0": {
        "wmdb\\T3cmsComposerInstaller": "Classes/"
    }
},

我的文件结构如下:

/Classes/
     wmdb/
        T3cmsComposerInstaller/
            [Code classes go here]

这有帮助吗?