zen of coding

Setting up Nginx and CakePHP 2.0

Nginx is a pretty awesome web server (fast, and easy to configure… at least I prefer the syntax over some other popular web servers). I figured to share the installation process of both CakePHP 2.0 and Nginx on Ubuntu 11.04 (Natty). Let’s fire up the terminal… (I presume you have[…]

Read More »

Quick comparison of Nginx and Apache

This was a quick test as I was playing around with Nginx and CakePHP 2.0. The numbers were interesting, however. What I did: – Setup a virtual box with Windows host – OS: Ubuntu (Natty) – PHP 5.3.8 – CakePHP 2.0-beta (freshly pulled) – apache2 (2.2.17) – nginx (1.0.5) Nothing[…]

Read More »

Under the hood of CakePHP 2.0

Thanks to excellent Mr. jrbasso for putting together this list for me. In case one wonders, yes he does know a few things about cake ;) So, without further ado here’s a couple of things to enjoy in CakePHP 2.0… __() now works like sprintf() There were a few complaints[…]

Read More »

Setup debugging for Netbeans + CakePHP

Update (7/22/2011): dogmatic69 pointed out that you can do the same with Chrome by installing the xdebug extension. See his comment for details. For all the Netbeans users out there, if you don’t have debugging enabled, this little “how-to” should get you stared pretty easily. First prerequisite is to make[…]

Read More »

Offload read queries to a replica DB for better performance

In most web application, which require a lot of find()’s especially if more than a couple of models are involved, you should probably consider offloading those operations to read-only replica of your DB. This is typically achieved by having a master/slave or master/master configuration. In high traffic application you might[…]

Read More »

If you use UUID’s…

Be extra careful to make sure that, according to convention, your ‘id’ column (or primary key) is: char(36) and never varchar(36) CakePHP will work with both definitions, however you will be sacrificing about 50% of the performance of your DB (MySQL in particular). This will be most evident in more[…]

Read More »

find(‘first’)… gotcha

Just a simple tip… Here’s a typical find() example: [cc lang=”php”] $this->Post->find(‘first’, array(‘condition’ => array(‘id’ => 5))); [/cc] Why does it return me the post with ID = 1, rather than ID = 5? Of course, a careful reader spotted the spelling issue in the key: ‘condition’ instead of ‘conditions’.[…]

Read More »

Installing membase/memcached

These are instructions for getting membase/memcached installed in your local environment. (I was installing on windows so your setup might be a little different, but general approach is mostly the same). 1. Download the membase server for your OS (community edition is the one you are after): http://www.couchbase.com/downloads Once downloaded,[…]

Read More »

Speed up your pagination with a simple hack…

Before I go into the example in this little post, let me just say that this situation won’t be applicable to everyone… But let’s consider the following: We have a table with tens of thousands of records, that need to be paginated. As you know, cake will execute two queries;[…]

Read More »

Dealing with static pages v2 (or… 3?)

Over the years of cake development we’ve seen a number of ways to get rid of the the /pages/ path in the URL for static pages. By default if you create an “about us” page, such as in app/views/pages/about.ctp, the resulting URL would be: www.example.com/pages/about I’m sure you’ve seen a[…]

Read More »
%d bloggers like this: