Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How common is PEAR in the real world?

I have looked at a good deal of other peoples source code and other open source PHP software, but it seems to me that almost nobody actually uses PEAR.

How common is PEAR usage out in real world usage?

I was thinking that maybe the current feeling on frameworks may be affecting its popularity.

like image 372
patricksweeney Avatar asked Apr 10 '09 00:04

patricksweeney


2 Answers

PHP programmer culture seems to have a rampant infestation of "Not Invented Here" syndrome, where everyone appears to want to reinvent the wheel themselves.

Not to say this applies to all PHP Programmers, but them doing this apparently far too normal.

Much of the time I believe its due to lack of education, and that combined with difficulty of hosting providers providing decent PHP services.

This makes getting a workable PEAR installation so much more difficult, and its worsened by PHP's design structure not being favorable to a modular design.

( This may improve with the addition of namespaces, but have yet to see ).

The vast majority of PHP code I see in the wild is still classic amateur code interpolated with HTML, and the majority of cheap hosting that PHP users inevitably sign up for doesn't give you shell access.

like image 178
Kent Fredric Avatar answered Nov 02 '22 00:11

Kent Fredric


In my (limited) experience, every PEAR project that was potentially interesting had major points against it:

  • Code is targetted at the widest audience possible. There are hacks in place all over the place to deal with old/unsupported PHP versions. New useful features are ignored if they can't be emulated on older versions, meaning you end up lagging behind the core language development.
  • Any given project tends to grow until it solves everyone's problem with a single simple include. When your PHP interpreter has to process all of that source code on every page hit (because the authors may not have designed it to be opcode-cache-friendly), there is a measurable overhead for processing thousands of unused lines of code.
  • Style was always inconsistent. It never felt like I was learning generalizable APIs like in other languages.

I used to use PEAR::DB at work. We discovered that most of our scripts spent their time inside PEAR code instead of our own code. Replacing that with a very simple wrapper around pgsql_* functions significantly reduced execution time and increased runtime safety, due to the use of real prepared statements. PEAR::DB used its own (incorrect at the time) prepared-statement logic for Postgres because the native pgsql_ functions were too new to be used everywhere.

Overall, I feel like PEAR is good as a "starter library" in many cases. It is likely to be higher quality code than any individual will produce in a short amount of time. But I would certainly not use it in a popular public-facing website (at least, not without a lot of tweaking by hand... maintaining my own fork).

like image 24
Tom Avatar answered Nov 01 '22 23:11

Tom