What are differences between PECL and PEAR?
Asked Answered
T

6

150

I can see that GD library is for images. But I can't see differences between PECL and PEAR. Both have authentication. What are the main differences between two? Why don't they combine them?

Tokenism answered 6/9, 2009 at 10:19 Comment(0)
I
287

PECL stands for PHP Extension Community Library, it has extensions written in C, that can be loaded into PHP to provide additional functionality. You need to have administrator rights, a C compiler and associated toolchain to install those extensions.

PEAR is PHP Extension and Application Repository, it has libraries and code written IN php. Those you can simply download, install and include in your code.

So, yes they are similar, but yet so different :)

Idio answered 6/9, 2009 at 10:23 Comment(5)
Very clear answer. I would add that PEAR is really two things: It's a repository of libraries, but it's also a distribution channel/packaging system. Originally, the packaging system just distributed the single PEAR repository, but today, the distribution channel can be used by any third party library.Neuron
@troelskn, You call that a "distribution channel"? How is it different from a normal tomdickharry PHP library? Are you going to call jQuery a "distribution channel" too?Dodson
@troelskn, Actually jQuery and tom and harry has clearly defined protocols as well. What's the thing about PEAR that makes it different from them?Dodson
@Dodson Last time I looked, jQuery didn't have a package manager. In the js community, npm seems to fill this void these days (Although there have been other contestants over the years).Neuron
@Dodson PEAR is most definitely a manager of distribution channels. It is not a library, like jQuery. For example pear.php.net/manual/en/guide.users.commandline.channels.phpAnthropomorphize
H
14

PECL is a repository of C extensions for PHP. Those extensions are usually installed via the pecl command, which is an alias for pear, with the default channel/repository set to pecl.php.net.

PEAR is multiple things:

  1. The package installer (pear command) that is able to install packages from different channels (repositories), including pecl.php.net. Many consider composer the successor of the pear installer.
  2. The package repository http://pear.php.net/packages.php with ~600 libraries. Many of them are composer-installable.
  3. A PHP coding standard that is available with PHP_CodeSniffer.
Hep answered 23/3, 2017 at 8:8 Comment(1)
Feels like its more accurate/clear to say the PEAR ecosystem includes a coding standard?Highlander
T
7

pear is a php classes written in php Whereas pecl is extensions which not written in php and need compiling .

Terence answered 15/7, 2015 at 19:33 Comment(0)
L
2

PEAR as-such is not a coding standard. Instead PEAR "follows" a set coding standard that is encouraged within the PHP Community. This is however not the only coding standard that PHP users can follow, the ZF, for eg. recommends a slightly different standard.

Languish answered 16/5, 2011 at 16:24 Comment(0)
H
1

PEAR is also a coding standard ;-) php_codesniffer (install via $pear install php_codesniffer ) is a tool that will scan your code and hilight where it deviates from that or any other supported coding standard.

Hula answered 16/9, 2009 at 22:50 Comment(0)
M
1

From my understanding, PHP has modules and frameworks, both being its libraries, external modules, called extensions, live in its PECL repository, while frameworks, called packages, live in its PEAR repository.

One can use PEAR packages within PHP code by simply sourcing the source code files, but PECL extensions should be installed on the system and enabled in configuration files to link to the interpreter.

Also, PEAR packages are written in PHP and are plain-text scripts, while PECL extensions are written in C/C++ and are compiled binaries in their consummable form.

Extensions as the name suggest extend PHP with something it doesn't offer by itself yet, while packages are just a collection of PHP code, ie. everything you can do with PHP proper.

This is parallel to Perl's PM modules and XS extensions.


That said, my view may not be 100% accurate, but that's how I could settle this in my mind :-)

Mentality answered 9/5, 2022 at 17:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.