PEAR - Still Relevant?
I'm an advanced beginner trying to choose a PHP repository or framework that I can turn to as a reliable source of reusable code.
I really like the idea of PEAR, but am scared off by the lack of good/current documentation.
For example, most of the articles on PEAR are dated, there are no well-reviewed books available, and the official manual is extremely uninviting.
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 开发者_JAVA技巧it myself from scratch.
So I ask -- is PEAR a good long-term choice for reusable PHP code?
The level of documentation is up to the PEAR package in question; some are poor, but others are not. You can get an idea of the status of a package by looking at its page, checking out release dates, ticket activity etc.
Some very useful tools, e.g. phpunit and PHP CodeSniffer, use PEAR as their main distribution channel, and it would be hard to argue that these are no longer relevant.
I think that PEAR as a whole is definitely still relevant, and will continue to be so, but many individual packages are probably not.
Using a framework in no way prevents you from using PEAR packages as well; most frameworks (barring, perhaps, Zend which seems to be an everything-and-the-kitchen-sink-as-well type framework) don't include everything anyway, so there will still be a lot of things you'll want to do that aren't already covered.
Update 2013
It looks like composer has gained more traction these days, it's probably worth looking into as well.
You're comparing things which are not related. Pear is a PHP extension library - a simple collection of classes. CakePHP, Zend, etc, are frameworks that ship some logical functionality, nicely documented and well tested. They aim to "enforce" best practises for web development (MVC, for instance) and provide means to do that.
I'm an advanced beginner
I am not sure what that is :)
is PEAR a good long-term choice for reusable PHP code?
To be honest, in my 5 years of PHP addiction, I have rarely had a need to go the PEAR way. Right now, I can recommend looking at Zend Framework and Doctrine 2. They are both backed by good active community.
I'd say PEAR is a good resource for small snippets and specialized libraries. I prefer PEAR over any third party site or random forums for this purpose, since the code on there usually at least used to be maintained for a few versions and has a certain minimum level of quality. Even if a package is outdated, you can get a rough estimate of how mature the code is by looking at its history.
Frameworks or DALs are IMO out of scope of PEAR, so it's hardly comparable.
I rarely use PEAR, but if I can find a useful package on there I prefer it over any other source. I would say that PEAR didn't quite live up to what it was supposed to be though. It has not reached the status of Ruby gems or Python eggs, which is a bit of a shame.
Even if the code is no longer maintained, much of it will still function perfectly fine. With PHP, most things will work fine regardless of PHP version; at most they might throw a warning about a depreciated function. These things are usually easy to change.
As far as PEAR goes, I personally have never used it. I keep a collection of functions and classes that I have found from around the web inside a folder. Some of them that I have found, others that I have written.
I think your main criterion should be code that is reusable. Meaning that it is extremely flexible for various aspects of your project without the need to hack it up. My preferred way of doing this is by writing functions that take just one array for all settings. This allows the function to evolve just by adding more elements to the array to define more settings/options.
Have a look at the major MVC frameworks and read up on their code. Virtually all of them are actively maintained and follow a strict set of guidelines in code readability and usability. But as others mentioned, PEAR and the MVC frameworks are two different things. PEAR is a library of scripts that you can use anywhere, MVC frameworks are discipline oriented tools for developing entire projects.
精彩评论