Tag: PEAR
About
PEAR is short for "PHP Extension and Application Repository" and is pronounced just like the fruit. The purpose of PEAR is to provide:
- A structured library of open-source code for PHP users
- A system for code distribution and package maintenance
- A standard style for code written in PHP, specified here
- The PHP Extension Community Library (PECL), see more below
- A web site, mailing lists and download mirrors to support the PHP/PEAR community
PEAR is a community-driven project governed by its developers. PEAR's governing bodies are subdivided into the PEAR Group, Collectives, and a President. PEAR's constitution (adopted in March 2007) defining these groups is documented here. The PEAR project was founded in 1999 by Stig S. Bakken and quite a lot of people have joined the project.
From pear.php.net/manual/en/introduction.php
Since a couple of months now, I've been involved with PEAR as a contributor. Contributing to PEAR means adhering to the PEAR Coding Standards. Their standards have actually been thought over, and using them for projects (also outside of PEAR), leads to consistency, and makes it easier for many developers to understand each other's code.
Code can be scanned and checked for conformity using the PHP CodeSniffer package.
It took me a while to get rid...
If you're like me and you're interested in the stats of your website or blog, you might also want to know how many Diggs all of your articles have received. But that can become quite a pain when you have more and more articles, pages or blog posts. So why not let PHP retrieve the Digg count of your articles so you can use it in graphs or other statistic tools?
It's always a good idea to backup important data. Your files and settings can easily be archived. But how can you backup & restore all applications that you've installed over the last couple of years? Here's an easy trick that works for both desktops & servers, and that can also be used to synchronize installed packages in a web cluster, making all the servers run the same software.
Recently two of my articles reached the Digg frontpage at the same day. My web server isn't state of the art and it had to handle gigantic amounts of traffic. But still it served pages to visitors swiftly thanks to a lot of optimizations. This is how you can prevent heavy traffic from killing your server.
Every time a request hits your server, PHP has to do a lot of processing, all of your code has to be compiled & executed for every single visit. Even though the outcome of all this processing is often identical for both visitor 21600 and 21601. So why not save the flat HTML generated for visitor 21600, and serve that to 21601 as well? This will relieve resources of your web server and database server because less PHP often means less queries.
Not everyone knows about PHP's capabilities of making SSH connections and executing remote commands, but it can be very useful. I've been using it a lot in PHP CLI applications that I run from cronjobs, but initially it was a pain to get it to work. The PHP manual on Secure Shell2 Functions is not very practice or thorough for that matter, so I would like to share my knowledge in this how to, to make it a little less time consuming setting this up.
You want your website to be as safe as possible. So you'll typically want Open Basedir and Safe Mode to be on. When you're in a shared hosting environment, you'll find that any server administrator with a good sense of security will also have these restrictions in place. However security pretty much always limits functionality and this case is no different. Because what if you are caged in a restricted environment, and you would still like to use shared libraries like the ones provided by PEAR?