I’ve considered PHP frameworks (CakePHP, CodeIgniter, Symfony, Zend) and CMS frameworks (Drupal, Joomla, WordPress), but as a long-term solution, I want reusable code that isn’t going to add any unnecessary overhead.
In other words, I want code that was written for a single purpose that I can plug into my application where it’s needed without “borrowing” any more code than what the application requires – just like if I had written it myself from scratch.
So I ask – is PEAR a good long-term choice for reusable PHP code?
I take the lack of news of PEAR as a bad sign. Not to say all the code is bad, I’m sure a lot is still useful, but personally I wouldn’t be investing a lot of time into PEAR.
Zend Framework is probably more worthwhile, and it has been designed to work in a decoupled way, so you don’t need to base your app on the framework to use specific components.
It seems like there are some projects that use it… recently when installing Drupal/CiviCRM on a virtual LAMP appliance and also while setting up a full install of XAMPP I saw ‘PEAR’ go flying by…
The concept seems sound… why have to re-invent the wheel of figuring out how to implement everything from scratch over and over and over and over…
Seems kind of odd that Perl has CPAN and Python (now) has PyPy (assuming these are roughly analagous…) why PHP PEAR (not tied to any one vendor) hasn’t gotten more of a foothold in the community?
If you want to avoid overhead, you can always just use OO PHP and make various classes. Then you can just reuse those classes wherever you want… without even needing access to the server.
Really it depends what type of reusable code you’re considering…
Pear is a generalized packaging and coding standard, the libraries are for any purpose. This is not true for something like Zend Framework, its specialized in web libraries and libraries for helping with the web. Both Pear and Zend Framework are dependency crazy.
So the question at hand is, is it still relevant? Very much so, its the defacto for library installation. Python has “Cheese Shop” and easy_install / pip, well php has Pear and Pecl.
Some of the documentation might be lacking, and thats the true for Cheese Shop, because its driven with singularity. How much depth a given library’s documentation has is on the creator of the library, not Pear as a community.
I haven’t ever used any PEAR class and I have been programming in PHP for over 5 years. Since I started using Zend Framework I rarely need to do anything that cannot be achieved with some class already included in the framework.
I intended on using PEAR for a couple of projects but on shared servers the admin are not very keen to install the packages.
So what is the point on using PEAR on a website and when you come to upload it the hosts will not install it ?
When you go to check out what is available as has been said before the documentation is lacking and when I see it has not been updated for a couple of years I think is it worth using ?
I have never considered PECL but Imagick is one of the packages and most of the documentation says.
This function is currently not documented; only its argument list is available.
I tried a couple of tests with it and found that some of the documentaion that exists is also incorrect.
Uhm, since when? Not on any of my servers it doesn’t… (and I do debian installs using howtoforge’s “perfect setups”)
But then I’ve never once actually seen a working PEAR install – I always figured it was a myth akin to a faster version of RUBY Duke Nukem whenever.
Ok, bad examples, but you get the idea.
From my experiences with it, I liken it to coldfusion or XML based databases-- one of those things I can’t believe anyone actually bothers trying to use in the first place since frankly, they are grossly inefficient and extremely poorly thought out.
I’ve become a fan of CodeIgniter and now use it for all my websites. As with any framework, there’s a bit of a learning curve, but they have very good documentation, an active forum, and a number of tutorials.
PEAR has some useful classes, but generally I have given up on PEAR. Too many outdated classes that still written for php4. Some don’t work with php5.3, some work but still the code looks so bad that I don’t want to use it.
Again, some classes are OK but usually I still have to make some changes to them before I can use them.
As a framework Zend or Symfony are much better than PEAR.
My only experience with PEAR was sending mail, and at the time I had a host that changed server settings and messed that up. I really tried to like PEAR, but between the complicated install and what happened with that host, I just gave up. I’m now using CodeIgniter, and I love it. I’ve got a couple instant website applications, and I can have a website up and running with all the features you’d expect in a well thought out website, in about an hour.
My only experience with PEAR is everytime I install PHPUnit. And let’s just say it’s broken if you try to do it on some WAMP packages, better do it on other OS.
To answer the original question, no - I do not think PEAR is no longer relevant. Every time I’ve had to maintain a site with PEAR code in it I’ve wanted to scream - there’s some really crappy crap in that library. It’s almost as bad as smarty.
Dependency is one of the reasons I avoid using it in any of my scripts. It seems rather pointless to depend on something that one host might let you use, the host goes down the pan and then you move to another who refuses it. Instead I’ve found myself building a rather large ‘utils.php’ file which has a ton of functions written by me which can be used for all sorts of things.
I’ll admit though, apart from being named after a horrible tasting fruit, I never really understood pear either. By default when you download the windows php zip it bambles on about pear in several places but doesn’t clearly tell you exactly what it is, what it does, how to use it, configure it or install it etc. IT just seemed to assume that you knew all about it which frankly isn’t very helpful.
I now try to avoid using external dependencies, I just try to write my own code and import / edit other peoples code if needed.