How do I get PEAR.php with Composer?

2020-07-27 06:27发布

问题:

I installed pear/archive_tar to work with Phing, which I installed with Composer. However, I received this error:

BUILD FAILED
exception 'BuildException' with message 'Error reading project file [wrapped: You must have installed the PEAR Archive_Tar class in order to use TarTask.]' in vendor/phing/phing/classes/phing/parser/ProjectConfigurator.php:197

I added the PEAR repository to Composer and updated, but it still did not work.

The second half of this question branched off here.

回答1:

I set my composer.json to this, and it was fixed:

{
    "repositories": [
        {
            "type": "pear",
            "url": "http://pear.php.net"
        }
    ],
    "require": {
        "phing/phing" : "2.6.1",
        "pear-pear.php.net/pear": "*"
    }
}

Native Composer libraries such as this do not work, because Composer does not add the pear/archive_tar package to the autoloader:

{
    "require": {
        "phing/phing" : "2.6.1",
        "rsky/pear-core-min" : "dev-master",
        "pear/archive_tar" : "1.3.11"
    }
}