PEAR和Composer有什么区别?

时间:2021-12-24 20:14:02

PEAR is used to install a PHP software package and Composer is used for the same thing. I believe Composer handles dependencies better but is that the only difference? Can anybody explain the difference between these two package managers and tell me when to use which?

PEAR用于安装PHP软件包,Composer用于同样的事情。我相信Composer能更好地处理依赖关系,但这是唯一的区别吗?任何人都可以解释这两个包管理器之间的区别并告诉我何时使用哪个?

1 个解决方案

#1


30  

It might be a bit soon to regard PEAR as deprecated but I don't believe it will take long before it is. Composer is thriving and mature with a lot of packages and and active development. Therefore it might be better to use Composer as the standard for package management tool in PHP.

将PEAR视为弃用可能有点不久,但我认为它不会花费很长时间。 Composer正在蓬勃发展并成熟,拥有大量的软件包和积极的开发。因此,最好使用Composer作为PHP中包管理工具的标准。

Using PEAR is more cumbersome for package maintainers. Therefore a lot of the code on PEAR is outdated. A developer needs to get it packages 'PEAR-reviewed' before it might get published on PEAR, so few packages are available compared to the number of packages available in Composer. Also, there is no way to install a package in PEAR for one single project. All packages are installed globally. With Composer you can install packages one a per-project basis or globally. Well and then there is the lack of dependency management in PEAR, which frankly should be the one thing a package manager does well.

使用PEAR对于包维护者来说更麻烦。因此,PEAR上的很多代码已经过时了。开发人员需要在PEAR上发布包之前对其进行“PEAR审核”,因此与Composer中可用的包数相比,可用的包很少。此外,没有办法在PEAR中为一个项目安装包。所有包都是全局安装的。使用Composer,您可以按项目或全局安装软件包。那么PEAR缺乏依赖管理,坦率地说应该是包管理器做得好的一件事。

One thing you can do with PEAR and not with Composer is installing PECL extensions. There is however pickle which uses Composer and lets you define native PHP extentions dependencies in your composer.json file. The pickle project is momentarily undergoing quite some development and should not yet be considered mature.

使用PEAR而不是使用Composer可以做的一件事是安装PECL扩展。然而,有些pickle使用Composer,并允许您在composer.json文件中定义本机PHP扩展依赖项。泡菜项目暂时经历了一些发展,不应该被认为是成熟的。

This blog post by Fabien Potencier might be a bit opinionated, but I think it is quite right. If you have an option, choose Composer so PEAR can die in peace. Even when you ask the PEAR maintainers most will tell you that Composer is the way forward, although some might still have their hopes for Pyrus. (This was intended to be PEAR improved, but got kindof buried under the exploding popularity of Composer.)

Fabien Potencier撰写的这篇博文可能有些自以为是,但我认为这是非常正确的。如果您有选择,请选择Composer,这样PEAR就可以安心死亡。即使你问PEAR维护者,大多数人都会告诉你Composer是前进的方向,尽管有些人可能仍然希望Pyrus。 (这是为了改进PEAR,但在Composer的爆炸式普及下被埋没了。)

By the way, you can use Composer to install PEAR packages as well, see the Composer documentation.

顺便说一句,您也可以使用Composer来安装PEAR包,请参阅Composer文档。

See also:
[1] Informative slide deck about PHP package management

另请参阅:[1]关于PHP包管理的信息性幻灯片

#1


30  

It might be a bit soon to regard PEAR as deprecated but I don't believe it will take long before it is. Composer is thriving and mature with a lot of packages and and active development. Therefore it might be better to use Composer as the standard for package management tool in PHP.

将PEAR视为弃用可能有点不久,但我认为它不会花费很长时间。 Composer正在蓬勃发展并成熟,拥有大量的软件包和积极的开发。因此,最好使用Composer作为PHP中包管理工具的标准。

Using PEAR is more cumbersome for package maintainers. Therefore a lot of the code on PEAR is outdated. A developer needs to get it packages 'PEAR-reviewed' before it might get published on PEAR, so few packages are available compared to the number of packages available in Composer. Also, there is no way to install a package in PEAR for one single project. All packages are installed globally. With Composer you can install packages one a per-project basis or globally. Well and then there is the lack of dependency management in PEAR, which frankly should be the one thing a package manager does well.

使用PEAR对于包维护者来说更麻烦。因此,PEAR上的很多代码已经过时了。开发人员需要在PEAR上发布包之前对其进行“PEAR审核”,因此与Composer中可用的包数相比,可用的包很少。此外,没有办法在PEAR中为一个项目安装包。所有包都是全局安装的。使用Composer,您可以按项目或全局安装软件包。那么PEAR缺乏依赖管理,坦率地说应该是包管理器做得好的一件事。

One thing you can do with PEAR and not with Composer is installing PECL extensions. There is however pickle which uses Composer and lets you define native PHP extentions dependencies in your composer.json file. The pickle project is momentarily undergoing quite some development and should not yet be considered mature.

使用PEAR而不是使用Composer可以做的一件事是安装PECL扩展。然而,有些pickle使用Composer,并允许您在composer.json文件中定义本机PHP扩展依赖项。泡菜项目暂时经历了一些发展,不应该被认为是成熟的。

This blog post by Fabien Potencier might be a bit opinionated, but I think it is quite right. If you have an option, choose Composer so PEAR can die in peace. Even when you ask the PEAR maintainers most will tell you that Composer is the way forward, although some might still have their hopes for Pyrus. (This was intended to be PEAR improved, but got kindof buried under the exploding popularity of Composer.)

Fabien Potencier撰写的这篇博文可能有些自以为是,但我认为这是非常正确的。如果您有选择,请选择Composer,这样PEAR就可以安心死亡。即使你问PEAR维护者,大多数人都会告诉你Composer是前进的方向,尽管有些人可能仍然希望Pyrus。 (这是为了改进PEAR,但在Composer的爆炸式普及下被埋没了。)

By the way, you can use Composer to install PEAR packages as well, see the Composer documentation.

顺便说一句,您也可以使用Composer来安装PEAR包,请参阅Composer文档。

See also:
[1] Informative slide deck about PHP package management

另请参阅:[1]关于PHP包管理的信息性幻灯片