Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between PEAR and Composer?

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?

like image 731
Sohel Ahmed Mesaniya Avatar asked Dec 10 '15 10:12

Sohel Ahmed Mesaniya


People also ask

What is PEAR in PHP What are the differences between PECL and PEAR?

pear is a php classes written in php Whereas pecl is extensions which not written in php and need compiling . Show activity on this post. PEAR as-such is not a coding standard. Instead PEAR "follows" a set coding standard that is encouraged within the PHP Community.

What is the use of PEAR in PHP?

As noted previously, PEAR is short for "PHP Extension and Application Repository." The purpose of PEAR is to provide the following: A structured library of open-source code for PHP users. A system for code distribution and package maintenance. A standard style for code written in PHP.


1 Answers

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.

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.

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.

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.)

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

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

like image 116
Xatoo Avatar answered Oct 19 '22 23:10

Xatoo