What is the difference between PEAR and PEAR2? What is the difference between PEAR and PEAR2? php php

What is the difference between PEAR and PEAR2?


First of all, the PEAR repository and PEAR installer are two separate things.

PEAR2 is the next generation of the PEAR repository, Pyrus is the next generation of the PEAR installer.

The PEAR repository has a set of standards for all packages released there. Likewise, the PEAR2 repository has standards each package must conform to. Unfortunately wiki.php.net which has all the details is down at the moment, but here's the basic differences between PEAR standards and PEAR2 standards.

  • PEAR2 packages are PHP 5.3+ only
  • All code is under the PEAR2 namespace
  • Each package must use package.xml v2.0
  • Files autoload with PSR-0 autoloader
  • require_once is not allowed
  • Packages should not be tied to the filesystem they're installed to
  • New versioning standards allow breaking BC without renaming the package
  • Packages should extend SPL Exceptions, and implement a base Exception interface

Pyrus, the new installer, is actually a self-contained phar archive and requires no complex installation. The new installer supports many features that improve upon the original PEAR installer, and can install existing pear packages from pear.php.net, pear2.php.net, and other pear-compatible channels.

The code within the pyrus.phar file complies with the PEAR2 coding standards, and therefore is in the PEAR2 repository and can be installed if you'd like to use it as a vendor library.

With the pear installer you would usepear install pear/Net_URL2

With pyrus, php pyrus.phar install pear/Net_URL2

When you install a package which conforms to the PEAR2 standards, you can safely move it to another location, commit to a repository, and the installs aren't tied to a specific machine. This makes it much easier to create a vendor directory containing libraries your application needs and share this with others.

There's quite a bit more, but that's the basics of PEAR2 and Pyrus.