What is Your Fav PHP Framework?

View Results

Loading ... Loading ...

I have touched on PHP frameworks before that has sparked up a lot of discussion.  A lot of people swear by one framework and other developers another.  Before you first get into one you might want to ask yourself if you need to use a PHP framework.  You might not even need to use one.  But the fact is that over time, they can significantly reduce development time.

Okay, so let’s say that you are new to PHP frameworks.  There are a few popular choices out there to sink your teeth into, but which one?  You don’t want to pick a framework to spend days upon days learning the architecture, only to find out that no other PHP developers out there are using that framework.  Thus making the time you spent learning the framework’s ins and outs a waste of time.

In a perfect world, I would suggest to learn them all!  However, there are only 24 hours in a day, and prioritizing your PHP framework education might be a good idea. So above I added a poll that I plead to other PHP developers out there to vote on.  Hopefully after a lot of participation we will see the most popular PHP framework.

Remember, BrownPHP is a site that helps other PHP developers.  By us learning what the most popular PHP frameworks, it will allow us to become more efficient, and ultimately more successful!  If you do feel strongly about one PHP framework over another, please leave a comment and explain why you chose the PHP framework that you did.

peg-hole-punch-pvc-plastic-laminate-lassco-wizer-os-php Peg Hole Punch PVC plastic laminate Lassco Wizer OS-PHP
US $75.00
Auction Ends: Tuesday Jan-06-2009 5:09:21 PST
Buy this Item   | Watch this Item
3-300-gb-web-hosting-cpanel-php-perl-free-ship-nr-0-01 3/300 GB Web Hosting Cpanel PHP Perl Free Ship NR 0.01
US $0.16 (3 Bids)
Auction Ends: Tuesday Jan-06-2009 7:42:15 PST
Bid on this Item   | Buy this Item   | Watch this Item
70+-php-clone-website-scripts-youtube-myspace-facebook 70+ Php Clone Website Scripts YouTube MySpace Facebook
US $5.95
Auction Ends: Tuesday Jan-06-2009 8:30:16 PST
Bid on this Item   | Buy this Item   | Watch this Item
php-perl-cgi-massive-power-scripts-collection-on-cdrom Php Perl Cgi Massive Power Scripts Collection on Cdrom
US $7.29 (0 Bid)
Auction Ends: Tuesday Jan-06-2009 12:36:39 PST
Bid on this Item   | Buy this Item   | Watch this Item
December 17, 2008 · Posted in PHP Articles  
    

Let me tell you a little story.  My latest site I have been working on for some time was written using the Zend Framework.  Since it was launched in Oct 07, it has been growing rapidly enough where I am now starting to feel growing pains.

One morning I went into the site to check some analytics, and my site was displaying a 403 Forbidden error!  I suddenly got a cold nervous sweat down the back of my spine.  Why was it forbidden?  It was fine when I checked it out last night?!  So I tried to login to my FTP account.  No go!  I I thought a hacker has some how blocked me out of my own account. [Exit dramatic build up].

I come to find out that my hosting company revoked my access to the folder that I was using for the domain.  I called them up immediately after I noticed that.  They responded by telling me that on a shared server, they limit their clients to use only 2% of the servers resources before they shut them down.  My site was using 30%. They were then forced to shut the site down without notice, because it was most likely affecting the performance of the other sites running from that shared server.

After some negotiating and explaining to them that I was going to come up with a solution, they temporarily gave me back access to the folder so that I could diagnose further what was going on.  The first thing that I did was looked through the server logs.  Because of my unfortunate neglect, the server log file was freaking enormous bigger than normal.

Nearly all of the errors I was getting were:

[03-Jul-2008 09:41:19] PHP Fatal error:  Uncaught exception ‘Zend_Db_Adapter_Exception’ with message ‘SQLSTATE[42000] [1203] User blank already has more than ‘max_user_connections’ active connections’ in blah blah blah

I’ll admit, I was in a huge hurry to get this project done, so I wasn’t thinking about the long tern effects.  Needless to say, I wasn’t caching my MySQL query results. I know, tisk tisk. Once I discovered this, I added this private method to my classes:


private function loadCache()
{
$frontendOptions = array(
'lifetime' => 7200, // cache lifetime of 2 hours
'automatic_serialization' =>
true);
$backendOptions = array(
'cache_dir' => './cache/' // Directory where to put the cache files
); // getting a Zend_Cache_Core object
return Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
}

Then in each of my classes where I needed to cache my query results, I implemented the above method. Here is an example:


class IndexController extends Zend_Controller_Action {
/**
* Index Action
*
*/
public function indexAction() {
$db = new SomeDB;
$cache = $this->loadCache();
if (!$results = $cache->load('cache_variable')) {
$results = $db->fetchAll('columnName="whatIWant"');
$cache->save($results, 'cache_variable');
}
}
}

It’s pretty much as simple as that.  Once I did this, it dropped the server load tremendously, which now buys me more time from upgrading my hosting package.  About 10 minutes of coding just saved me about $50 a month in hosting fees!  That feels good.

Keep in mind that this is not the best approach to solving this problem.  If you too are using the Zend Framework in your own design.  It was be better to initialize the Zend_Cache in your bootstrap file.  Doing it the way I did above will force you to replicate the code method, loadCache, in all of your classes which I dont’ have to explain to you why this is inefficient, and just plain old bad OOP technique! :P

July 3, 2008 · Posted in PHP Links, Zend Framework