Dependency Management with PEAR and PECL

dependency-managementLet us start with PEAR and PECL, since they are the oldest and have been available since 1999.

Both PEAR and PECL are hosted on PHP website, so they are in a sense, offical package manager for PHP applications, frameworks and libraries.

PEAR deals with framework and libraries, while PECL is more focused on PHP extensions.

PECL are programmed with C language since it extends the PHP language capabilites.

From PEAR website:

PEAR is short for “PHP Extension and Application Repository” and is pronounced just like the fruit. The purpose of PEAR is to provide:

  • 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, specified here
  • The PHP Extension Community Library (PECL), see more below
  • A web site, mailing lists and download mirrors to support the PHP/PEAR community

Source: PEAR

Similar to Linux package manager concept (used by RedHat and Debian), PEAR packages can be installed via PEAR own script. And distribution can also be stored outside official PEAR repository. Such distribution location are called channels.

As mentioned in the previous article, PEAR packages, when installed are available to all projects on the same server.

This is the primary difference with Composer. As with Composer, the packages are installed specific for a project.

So, PEAR is suitable if your project or application are divided into modules and they use the same libraries / framework. It is more economical to install PEAR. Because, if we take each modules as projects and all modules use the same library, we will only have to install and manage one PEAR library.

Whereas, with Composer, if for example there are 10 modules, we will have to manage 10 different Composer projects.

It is easier to use PEAR and it also saves storage space.

Now, PEAR have a lot of shortcoming, especially its learning curve. It is quite steep and most people, including developers just like to have one simple step to execute. Not many steps. Which perhaps explains its slow to rise in PHP world.

However, when it was first introduced, it was very popular because the first package manager for PHP and it does help developers re-use code.

So, tommorrow, we will discuss Composer, the very popular dependency manager for PHP today.