<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>nuts and bolts of cakephp</title>
	
	<link>http://nuts-and-bolts-of-cakephp.com</link>
	<description />
	<lastBuildDate>Tue, 14 Feb 2012 20:46:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/NutsAndBoltsOfCakephp" /><feedburner:info uri="nutsandboltsofcakephp" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>“Error: Database connection “Mysql” is missing, or could not be created”. CakePHP 2.0 — cake bake trouble</title>
		<link>http://feedproxy.google.com/~r/NutsAndBoltsOfCakephp/~3/RkaKi5zqtNc/</link>
		<comments>http://nuts-and-bolts-of-cakephp.com/2012/02/14/error-database-connection-mysql-is-missing-or-could-not-be-created-cakephp-20-cake-bake-trouble/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 14:35:45 +0000</pubDate>
		<dc:creator>teknoid</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[cake bake]]></category>
		<category><![CDATA[cake pdo]]></category>
		<category><![CDATA[cakephp 2.0]]></category>
		<category><![CDATA[mysql pdo]]></category>
		<category><![CDATA[php cli pdo]]></category>

		<guid isPermaLink="false">http://nuts-and-bolts-of-cakephp.com/?p=1357</guid>
		<description><![CDATA[CakePHP 2.0 Nothing like coming back from a hiatus with a WTF? post. My favorite &#8220;cake bake&#8221; started failing with the message in the subject; as well it seems that I am not the only one who had suffered from the problem&#8230; (just give it a quick check on google). After a little research here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>CakePHP 2.0</p>
<p>Nothing like coming back from a hiatus with a WTF? post.<br />
My favorite &#8220;cake bake&#8221; started failing with the message in the subject; as well it seems that I am not the only one who had suffered from the problem&#8230; (just give it a quick check on google).</p>
<p>After a little research here&#8217;s a summary of issues and steps to check:</p>
<p>The problem is caused the the fact that the PDO drivers are not available when you run php5 in cli mode (i.e. &#8220;cake bake&#8221;).</p>
<ol>
<li>First thing you&#8217;d want to check is which php.ini file is being used by your php (in cli mode!).</li>
<li>In your terminal (or command prompt), run: <code>php --ini.</code> This will show the location of the currently used files. In many cases it is possible that your system php is not the same as your web server php, which you might have installed with something like XAMPP. If this is the case you need to change your path to use the correct install of php, which should have the necessary drivers available.</li>
<li>
Next step would be to check your php.ini (which is sometimes broken into a few config files). Check the PDO settings to make sure you have the correct extension enabled (might be as simple as un-commenting a line). For example, I am using MySQL therefore I needed to have MySQL PDO extension available (when running in cli!). It was working perfectly well &#8220;on the web&#8221;.
</li>
<li>
Turns out I needed to run: <code>sudo apt-get install php5-mysql</code>
</li>
</ol>
<p>That was unexpected a little since CakePHP had no connection problems to MySQL, but there you go. This should cover all possible cases.<br />
If you find other solutions not outlined here, please share.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/UAPjb2tjqiIc-PMsnrAi4D_b3V0/0/da"><img src="http://feedads.g.doubleclick.net/~a/UAPjb2tjqiIc-PMsnrAi4D_b3V0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/UAPjb2tjqiIc-PMsnrAi4D_b3V0/1/da"><img src="http://feedads.g.doubleclick.net/~a/UAPjb2tjqiIc-PMsnrAi4D_b3V0/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=RkaKi5zqtNc:jRY4p-B6pss:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=RkaKi5zqtNc:jRY4p-B6pss:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=RkaKi5zqtNc:jRY4p-B6pss:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=RkaKi5zqtNc:jRY4p-B6pss:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:KwTdNBX3Jqk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=RkaKi5zqtNc:jRY4p-B6pss:KwTdNBX3Jqk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RkaKi5zqtNc:jRY4p-B6pss:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/NutsAndBoltsOfCakephp/~4/RkaKi5zqtNc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nuts-and-bolts-of-cakephp.com/2012/02/14/error-database-connection-mysql-is-missing-or-could-not-be-created-cakephp-20-cake-bake-trouble/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://nuts-and-bolts-of-cakephp.com/2012/02/14/error-database-connection-mysql-is-missing-or-could-not-be-created-cakephp-20-cake-bake-trouble/</feedburner:origLink></item>
		<item>
		<title>Setting up Nginx and CakePHP 2.0</title>
		<link>http://feedproxy.google.com/~r/NutsAndBoltsOfCakephp/~3/1kbv4JNICaA/</link>
		<comments>http://nuts-and-bolts-of-cakephp.com/2011/08/26/setting-up-nginx-and-cakephp-2-0/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 22:50:59 +0000</pubDate>
		<dc:creator>teknoid</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[cake 2]]></category>
		<category><![CDATA[cake2 and nginx]]></category>
		<category><![CDATA[cakephp 2.0]]></category>
		<category><![CDATA[cakephp nginx]]></category>
		<category><![CDATA[cakephp with nginx]]></category>

		<guid isPermaLink="false">http://nuts-and-bolts-of-cakephp.com/?p=1328</guid>
		<description><![CDATA[Nginx is a pretty awesome web server (fast, and easy to configure&#8230; 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&#8217;s fire up the terminal&#8230; (I presume you have some basic knowledge of *nix [...]]]></description>
			<content:encoded><![CDATA[<p>Nginx is a pretty awesome web server (<a href="http://nuts-and-bolts-of-cakephp.com/2011/08/26/quick-comparison-of-nginx-and-apache/">fast</a>, and easy to configure&#8230; at least I prefer the syntax over some other popular web servers).</p>
<p>I figured to share the installation process of both CakePHP 2.0 and Nginx on Ubuntu 11.04 (Natty).</p>
<p>Let&#8217;s fire up the terminal&#8230; </p>
<p>(I presume you have some basic knowledge of *nix so I won&#8217;t go into details about the commands, etc.)</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install git
</pre>
<p>Next, let&#8217;s get a fresh version of cake 2:</p>
<pre class="brush: plain; title: ; notranslate">
cd /cake
sudo git clone https://github.com/cakephp/cakephp.git
sudo git checkout 2.0
sudo git pull
</pre>
<p>Git should tell us that we are &#8220;up-to-date&#8221;.</p>
<p>Alright, now we have to setup our environment.<br />
The best way I found of going about it (after trying quite a few methods out there) is by the running the excellent set of scripts, which you can <a href="https://github.com/vladgh/VladGh.com-LEMP" target="_blank">find here</a>.<br />
Pull the scripts from the git repo, in the similar way as shown above, into some reasonable local destination. Once you have the files locally, simply run: </p>
<pre class="brush: plain; title: ; notranslate">sudo ./install.sh</pre>
<p>After answering a few questions&#8230; our LEMP environment is ready!</p>
<p>Let&#8217;s see if Nginx is working as expected&#8230;<br />
In the browser head over to localhost, at least at the time of this writing, you get a <code>phpinfo()</code> page served up by default.</p>
<p>So we are satisfied that Nginx is serving up PHP and now it&#8217;s time to setup a CakePHP 2.0 app.<br />
When we&#8217;ve pulled CakePHP in the very beginning, it came with a skeleton app, which we will use for growing our new one.</p>
<p>Let&#8217;s copy it someplace easily accessible (assuming we are in the root of cake&#8230; you should see &#8220;app&#8221;, &#8220;vendors&#8221;, &#8220;lib&#8221; directories):</p>
<pre class="brush: plain; title: ; notranslate">sudo cp -r app /web/</pre>
<p>In order not to move cake anywhere, we&#8217;ll create a symbolic link to our lib.<br />
(Presuming we are now in the &#8220;/web&#8221; directory):</p>
<pre class="brush: plain; title: ; notranslate">sudo ln -s /cake/cakephp/lib lib</pre>
<p>So at this point we have php, web server, cake core, skeleton app, mysql all ready to go.<br />
The only remaining part is to tell the web server about our cake app. Similarly to Apache we can setup virtual hosts and rewrite rules in Nginx. I don&#8217;t know many details about setting up Nginx and all the rewrite rule tricks available, but as mentioned before, from the examples the syntax looks quite simple and one should be able to decipher the directives relatively easily.</p>
<p>&#8230; Being lazy and not wanting to go through the docs, I googled around and thanks to <a href="http://blog.getintheloop.eu/2008/4/17/nginx-engine-x-rewrite-rules-for-cakephp/" target="_blank">this post</a> it was quite fast to setup a virtual host for the app.</p>
<p>After the installation Nginx will have a setting file in:<br />
<code>/etc/nginx/sites-available/default</code><br />
(This particular set of installation steps is applicable to Ubuntu, but hopefully you&#8217;ll know how to achieve the same procedure in your own OS).</p>
<p>If we review the file quickly it seems like a solid starting point, but we need to have some rewrite rules for cake to make pretty-urls work.<br />
Well, once again thanks to aforementioned post, all we have to do is add the snippet below to our default config (hey, at least it&#8217;s working for me):</p>
<pre class="brush: plain; title: ; notranslate">
# rewrite rules for cakephp
  location / {
    root   /web/app/webroot;
    index  index.php index.html;
    try_files $uri $uri/ index.php;

    # If the file exists as a static file serve it
    # directly without running all
    # the other rewite tests on it
    if (-f $request_filename) {
      break;
    }
    if (!-f $request_filename) {
      rewrite ^/(.+)$ /index.php?url=$1 last;
      break;
    }
 }
</pre>
<p>The <code>root</code> setting is pointing to our app&#8217;s webroot, of course&#8230; which in trun becomes the root of the virtual host (let&#8217;s just use localhost for now, otherwise you&#8217;d need to take a few additional steps, but that&#8217;s beyond the scope of this post).<br />
Hopefully the code of the setting is not too hard to figure out.</p>
<p>So at this point we have a virtual host pointing to our app and all the settings in place, let&#8217;s restart the web server:</p>
<pre class="brush: plain; title: ; notranslate">
sudo /etc/init.d/nginx restart
</pre>
<p>&#8230; and if all goes well, once you visit localhost in your browser, you should see the CakePHP 2.0 welcome page.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/zjxxGLBSr0-YwZCfDbXKxoAI0Sc/0/da"><img src="http://feedads.g.doubleclick.net/~a/zjxxGLBSr0-YwZCfDbXKxoAI0Sc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/zjxxGLBSr0-YwZCfDbXKxoAI0Sc/1/da"><img src="http://feedads.g.doubleclick.net/~a/zjxxGLBSr0-YwZCfDbXKxoAI0Sc/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=1kbv4JNICaA:zZQRH4Kk5do:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=1kbv4JNICaA:zZQRH4Kk5do:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=1kbv4JNICaA:zZQRH4Kk5do:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=1kbv4JNICaA:zZQRH4Kk5do:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:KwTdNBX3Jqk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=1kbv4JNICaA:zZQRH4Kk5do:KwTdNBX3Jqk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=1kbv4JNICaA:zZQRH4Kk5do:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/NutsAndBoltsOfCakephp/~4/1kbv4JNICaA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nuts-and-bolts-of-cakephp.com/2011/08/26/setting-up-nginx-and-cakephp-2-0/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://nuts-and-bolts-of-cakephp.com/2011/08/26/setting-up-nginx-and-cakephp-2-0/</feedburner:origLink></item>
		<item>
		<title>Quick comparison of Nginx and Apache</title>
		<link>http://feedproxy.google.com/~r/NutsAndBoltsOfCakephp/~3/NJbA6Nkz1Us/</link>
		<comments>http://nuts-and-bolts-of-cakephp.com/2011/08/26/quick-comparison-of-nginx-and-apache/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 05:04:15 +0000</pubDate>
		<dc:creator>teknoid</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cake 2.0]]></category>
		<category><![CDATA[cakephp 2.0]]></category>
		<category><![CDATA[cakephp nginx]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://nuts-and-bolts-of-cakephp.com/?p=1319</guid>
		<description><![CDATA[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 was tweaked or tuned. I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>This was a quick test as I was playing around with <a href="http://wiki.nginx.org/" target="_blank">Nginx</a> and CakePHP 2.0.</p>
<p>The numbers were interesting, however.<br />
What I did:<br />
- Setup a virtual box with Windows host<br />
- OS: Ubuntu (Natty)<br />
- PHP 5.3.8<br />
- CakePHP 2.0-beta (freshly pulled)<br />
- apache2 (2.2.17)<br />
- nginx (1.0.5)</p>
<p>Nothing was tweaked or tuned. I&#8217;ve setup both servers to use virtual hosts and simply load the default CakePHP page (i.e. fresh install).<br />
There is no app behind any of this, but we are touching pieces of the framework and some PHP logic.<br />
(Comparison is about the web servers anyway)&#8230;</p>
<p>Anyway, start apache and run:</p>
<pre class="brush: plain; title: ; notranslate">
ab -kc 10 -t 30 http://localhost/
</pre>
<p>So we&#8217;ll use <a href="http://httpd.apache.org/docs/2.0/programs/ab.html" target="_blank">apache benchmark</a> to beat the localhost a little (for 30 seconds) and get some numbers:</p>
<pre>
Benchmarking localhost (be patient)
Finished 839 requests

Server Software:        Apache/2.2.17
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        4481 bytes

Concurrency Level:      10
Time taken for tests:   30.009 seconds
Complete requests:      839
Failed requests:        0
Write errors:           0
Keep-Alive requests:    839
Total transferred:      4109432 bytes
HTML transferred:       3759559 bytes
Requests per second:    27.96 [#/sec] (mean)
Time per request:       357.679 [ms] (mean)
Time per request:       35.768 [ms] (mean, across all concurrent requests)
Transfer rate:          133.73 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.7      0       7
Processing:   203  355 121.7    352    2931
Waiting:      202  355 121.7    352    2931
Total:        203  355 122.0    352    2938

Percentage of the requests served within a certain time (ms)
  50%    352
  66%    360
  75%    365
  80%    368
  90%    377
  95%    385
  98%    393
  99%    404
 100%   2938 (longest request)
</pre>
<p>Now, shutdown apache, start nginx and repeat the above test:</p>
<pre>
Benchmarking localhost (be patient)
Finished 4451 requests

Server Software:        nginx/1.0.5
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        4481 bytes

Concurrency Level:      10
Time taken for tests:   30.001 seconds
Complete requests:      4451
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      21367368 bytes
HTML transferred:       19972014 bytes
Requests per second:    148.36 [#/sec] (mean)
Time per request:       67.403 [ms] (mean)
Time per request:       6.740 [ms] (mean, across all concurrent requests)
Transfer rate:          695.53 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       7
Processing:    18   67  11.6     67     204
Waiting:        5   40  22.1     42     198
Total:         18   67  11.6     67     204

Percentage of the requests served within a certain time (ms)
  50%     67
  66%     71
  75%     73
  80%     75
  90%     80
  95%     85
  98%     93
  99%    102
 100%    204 (longest request)
</pre>
<p>OK, let&#8217;s see:<br />
Total requests served: Apache &#8211; 839, Nginx &#8211; <strong>4451</strong><br />
Requests per second: Apache &#8211; 27.96, Nginx &#8211; <strong>148.36</strong></p>
<p>The other numbers are quite unbelievable as well.</p>
<p>What&#8217;s the point of all this? Tutorial on CakePHP 2.0 + Nginx is <del datetime="2011-08-26T22:51:13+00:00">coming soon</del> <a href="/2011/08/26/setting-up-nginx-and-cakephp-2-0/">here</a> ;)</p>

<p><a href="http://feedads.g.doubleclick.net/~a/8GuJsryJBiAYJa389d89HDZs-9Q/0/da"><img src="http://feedads.g.doubleclick.net/~a/8GuJsryJBiAYJa389d89HDZs-9Q/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/8GuJsryJBiAYJa389d89HDZs-9Q/1/da"><img src="http://feedads.g.doubleclick.net/~a/8GuJsryJBiAYJa389d89HDZs-9Q/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=NJbA6Nkz1Us:clMHMxhVMEQ:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=NJbA6Nkz1Us:clMHMxhVMEQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=NJbA6Nkz1Us:clMHMxhVMEQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=NJbA6Nkz1Us:clMHMxhVMEQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:KwTdNBX3Jqk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=NJbA6Nkz1Us:clMHMxhVMEQ:KwTdNBX3Jqk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=NJbA6Nkz1Us:clMHMxhVMEQ:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/NutsAndBoltsOfCakephp/~4/NJbA6Nkz1Us" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nuts-and-bolts-of-cakephp.com/2011/08/26/quick-comparison-of-nginx-and-apache/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://nuts-and-bolts-of-cakephp.com/2011/08/26/quick-comparison-of-nginx-and-apache/</feedburner:origLink></item>
		<item>
		<title>Under the hood of CakePHP 2.0</title>
		<link>http://feedproxy.google.com/~r/NutsAndBoltsOfCakephp/~3/IEUpEpzjfuM/</link>
		<comments>http://nuts-and-bolts-of-cakephp.com/2011/08/14/under-the-hood-of-cakephp-2-0/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 23:08:14 +0000</pubDate>
		<dc:creator>teknoid</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[cake 2.0]]></category>
		<category><![CDATA[cake 2.0 changes]]></category>
		<category><![CDATA[cake 2.0 performance]]></category>
		<category><![CDATA[cakephp 2.0]]></category>
		<category><![CDATA[cakephp 2.0 features]]></category>
		<category><![CDATA[caphp 2.0 speed]]></category>

		<guid isPermaLink="false">http://nuts-and-bolts-of-cakephp.com/?p=1290</guid>
		<description><![CDATA[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&#8217;s a couple of things to enjoy in CakePHP 2.0&#8230; __() now works like sprintf() There were a few complaints about this in the past, [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to excellent Mr. <a href="http://blog.cakephp-brasil.org/" target="_blank">jrbasso</a> for putting together this list for me.<br />
In case one wonders, yes <a href="https://github.com/jrbasso" target="_blank">he does know a few things</a> about cake ;)</p>
<p>So, without further ado here&#8217;s a couple of things to enjoy in CakePHP 2.0&#8230;</p>
<p><strong><code>__()</code> now works like <code>sprintf()</code></strong></p>
<p>There were a few complaints about this in the past, as well as the fact that <code>__()</code> used to <code>echo</code> by default.</p>
<p>Now the problem is fixed and the default usage is as follows:</p>
<pre class="brush: php; title: ; notranslate">
echo __(&quot;some %s var&quot;, $myVar);
</pre>
<p><strong>Improved file structure and lazy loading of files</strong></p>
<p>The naming convention is much better and simpler now. No more messing about with underscore&#8217;s, etc.<br />
Whatever you have for your class name is what you have for your file name (+&#8221;.php&#8221;).<br />
Misspelling of model file names ESPeciaALLY (e_s_pecia_a_l_l_y.php) in extreme cases was a common mistake for cake not being able to find the model.<br />
Therefore none of the model specific rules for validation, methods and other logic could be executed.<br />
(The simple debugging and good ol&#8217; copy/paste should be much easier now). </p>
<p><strong>New CakeRequest and CakeResponse</strong></p>
<p>First, <code>CakeRequest</code> gathers all information about the request (in a way like <code>$this->params</code> does, but with a lot more juice).<br />
For example, some responsibilities of the <code>RequestHandler</code> component have been shifted to <code>CakeRequest</code>.<br />
Mark Story has an <a href="http://mark-story.com/posts/view/the-cakerequest-object-in-cakephp-2-0" target="_blank">excellent write-up about this</a> if you wish to learn about<br />
the details.</p>
<p>The counterpart, of sorts, to <code>CakeRequest</code> is <code>CakeResponse</code>&#8230; which, as you&#8217;ve guessed, works to handle responding to requests.<br />
It consolidates the work, which was previously spread across various components of the system.<br />
Again, I will refer you to Mark Story&#8217;s blog to get <a href="http://mark-story.com/posts/view/cakeresponse-in-cakephp-2-0" target="_blank">detailed description about CakeResponse</a>. </p>
<p>The whole idea is to decouple and better organize related tasks from various places in the framework. Good organization helps with maintainability of the framework code, and, in turn, your own.</p>
<p><strong>CakeEmail is a Library now</strong></p>
<p>This change should stop 99% of the questions about how to send email from the model.<br />
Yaayy! You don&#8217;t have to break MVC anymore (in your <code>User</code> model):</p>
<pre class="brush: php; title: ; notranslate">
App::uses('CakeEmail', 'Network/Email');
class User extends AppModel {
  public function afterSave($created) {
    if ($created) {
      $email = new CakeEmail();
      $email-&gt;from('me@example.com')-&gt;to('new.user@example.com')-&gt;subject('Welcome')-&gt;send('Hello! This is my message to the new user.');
    }
  }
}
</pre>
<p>You don&#8217;t have to chain the methods as above&#8230;</p>
<p><strong>HTML5 methods in Form/Html helper</strong></p>
<p>Even though HTML5 is still a bit infant more and more web applications are beginning to apply its elements. This is especially true in the mobile market.<br />
CakePHP 2.0 has a clever way for the HTML5 implementation, by using the <a href="http://php.net/manual/en/language.oop5.overloading.php" target="_blank">magic</a> <code>__call()</code> method,<br />
to create simple inputs.</p>
<p>Let&#8217;s look at the test case to better understand this:</p>
<pre class="brush: php; title: ; notranslate">
/**
 * test that some html5 inputs + FormHelper::__call() work
 *
 * @return void
 */
	function testHtml5Inputs() {
		$result = $this-&gt;Form-&gt;email('User.email');
		$expected = array(
			'input' =&gt; array('type' =&gt; 'email', 'name' =&gt; 'data[User][email]', 'id' =&gt; 'UserEmail')
		);
		$this-&gt;assertTags($result, $expected);

		$result = $this-&gt;Form-&gt;search('User.query');
		$expected = array(
			'input' =&gt; array('type' =&gt; 'search', 'name' =&gt; 'data[User][query]', 'id' =&gt; 'UserQuery')
		);
		$this-&gt;assertTags($result, $expected);

		$result = $this-&gt;Form-&gt;search('User.query', array('value' =&gt; 'test'));
		$expected = array(
			'input' =&gt; array('type' =&gt; 'search', 'name' =&gt; 'data[User][query]', 'id' =&gt; 'UserQuery', 'value' =&gt; 'test')
		);
		$this-&gt;assertTags($result, $expected);
	}
</pre>
<p><strong>PDO and database access performance</strong></p>
<p>In 2.0 CakePHP is switching to the <a href="http://www.php.net/manual/en/intro.pdo.php" target="_blank">PDO</a>. PDO drivers are stable, native and well-supported. They obviously provide faster and better data access.</p>
<p><strong>Auth is more flexible and supports different authentication methods like &#8220;Digest&#8221;</strong></p>
<p>Authentication and Authorization are now properly decoupled from one another.<br />
In both cases an app developer has the ability to extend <code>BaseAuthenticate</code> or <code>BaseAuthorize</code> to add new authentication and authorization methods.<br />
CakePHP 2.0 comes with a few core methods (at least at the time of writing this): </p>
<ul>
<li>ActionsAuthorize &mdash; Provides the ability to authorize using the AclComponent</li>
<li>BasicAuthenticate &mdash; Provides Basic HTTP authentication support for AuthComponent</li>
<li>ControllerAuthorize &mdash; Provides the ability to authorize using a controller callback</li>
<li>CrudAuthorize &mdash; best explanation is taken from the code doc:<br />
<blockquote><p>
For example, taking `/posts/index` as the current request.  The default mapping for `index`, is a `read` permission check. The Acl check would then be for the `posts` controller with the `read` permission. This allows you to create permission systems that focus more on what is being done to resources, rather than the specific actions being visited.
</p></blockquote>
</li>
<li>DigestAuthenticate &mdash; Provides <a href="http://en.wikipedia.org/wiki/Digest_access_authentication" target="_blank">Digest HTTP authentication</a> support</li>
<li>FormAuthenticate &mdash; Authenticates the identity contained in a request (i.e. the good ol&#8217; login form)</li>
</ul>
<p>So much cleaner :)</p>
<p><strong>No more PHP4</strong></p>
<p>Nuff&#8217; said. This makes Cake 2.0 much faster (oh let&#8217;s say twice as fast), and no I don&#8217;t have evidence to support this claim, by removing a lot of uncessary code to support PHP 4 and 5, not to mention additional logic which would lead on one path or another depending what version of PHP you have installed.<br />
To be more specific, CakePHP 2.0 will support PHP 5.2+ (so it may not be utilizing some of the newer features of PHP 5.3).</p>
<p><strong>Using collections to load Helpers, Behaviors, Components</strong></p>
<p>From CakePHP <a href="http://cakephp.lighthouseapp.com/projects/42648/20-helper-behavior-component-and-task-refactor" target="_blank">lighthouse page</a>:</p>
<blockquote><p>
Helpers, behaviors, components, and tasks were restructured for 2.0. After examining the various things these objects did, there were some striking similarities. All the object types except Tasks provided callbacks and custom methods. However, the loading and usage of callbacks was slightly different in each case. For 2.0 these different loading/callback triggering API&#8217;s were simplified and made uniform. Using BehaviorCollection as the base of how things should work. Each object type now has a Collection object. This collection object is responsible for loading, unloading and triggering callbacks.<br />
&#8230;<br />
After examining the responsibilities of each class involved in the View layer, it became clear that View was handling much more than a single task. The responsibility of creating helpers, is not central to what View does, and was moved into HelperCollection. HelperCollection is responsible for loading and constructing helpers, as well as triggering callbacks on helpers. By default View creates a HelperCollection in its constructor, and uses it for subsequent operations. The HelperCollection for a view can be found at <code>$this->Helpers</code>.<br />
&#8230;<br />
Components were refactored in 2.0 to solve a number of inconsistencies and provide a more uniform API. In the past Component was the loader and manager of Components for a Controller. In 2.0 <code>ComponentCollection</code> takes over that responsibility and Component is now a base class for components. This unifies the API between Helpers and Components as a collection.<br />
Inside a controller <code>$this->Component</code> has been renamed to <code>$this->Components</code> this makes it more uniform with Behaviors and Helpers.
</p></blockquote>
<p><strong>Custom class names (aliasing) for your Helpers, Behaviors, Components</strong></p>
<pre class="brush: php; title: ; notranslate">
pulic $helpers = array(
    &quot;Html&quot; =&gt; array(
        &quot;className&quot; =&gt; &quot;CustomHtml&quot;
    )
);
</pre>
<p><strong>Plugins are not auto-loaded</strong></p>
<p>You will need to load them in your class or bootstrap.</p>
<p><strong>Models are now lazy loaded</strong></p>
<p>With all this talk about <a href="http://en.wikipedia.org/wiki/Lazy_loading" target="_blank">Lazy Loading</a>, this is probably the one that deserves a lot of attention.<br />
Besides, models will not attempt a DB connection until <code>find()</code> (or other DB-actionable) method is called.   </p>
<p>p.s. CakePHP 2.0 could be here sooner than people expect. I have a feeling we&#8217;ll have RC4 come CakeFest. So, if you have not started thinking about migrating your app to 2.0, now is a good time ;)</p>

<p><a href="http://feedads.g.doubleclick.net/~a/gkLdb1o05sNvSMDVgUQ7nkEPdfk/0/da"><img src="http://feedads.g.doubleclick.net/~a/gkLdb1o05sNvSMDVgUQ7nkEPdfk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/gkLdb1o05sNvSMDVgUQ7nkEPdfk/1/da"><img src="http://feedads.g.doubleclick.net/~a/gkLdb1o05sNvSMDVgUQ7nkEPdfk/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=IEUpEpzjfuM:6YIci57KLPU:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=IEUpEpzjfuM:6YIci57KLPU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=IEUpEpzjfuM:6YIci57KLPU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=IEUpEpzjfuM:6YIci57KLPU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:KwTdNBX3Jqk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=IEUpEpzjfuM:6YIci57KLPU:KwTdNBX3Jqk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=IEUpEpzjfuM:6YIci57KLPU:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/NutsAndBoltsOfCakephp/~4/IEUpEpzjfuM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nuts-and-bolts-of-cakephp.com/2011/08/14/under-the-hood-of-cakephp-2-0/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://nuts-and-bolts-of-cakephp.com/2011/08/14/under-the-hood-of-cakephp-2-0/</feedburner:origLink></item>
		<item>
		<title>Setup debugging for Netbeans + CakePHP</title>
		<link>http://feedproxy.google.com/~r/NutsAndBoltsOfCakephp/~3/qHxx8A_u2kk/</link>
		<comments>http://nuts-and-bolts-of-cakephp.com/2011/07/21/setup-debugging-for-netbeans-cakephp/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 19:11:45 +0000</pubDate>
		<dc:creator>teknoid</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[cakephp debugger]]></category>
		<category><![CDATA[cakephp netbeans]]></category>
		<category><![CDATA[cakephp xdebug]]></category>
		<category><![CDATA[netbeans xdebug]]></category>

		<guid isPermaLink="false">http://nuts-and-bolts-of-cakephp.com/?p=1272</guid>
		<description><![CDATA[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&#8217;t have debugging enabled, this little &#8220;how-to&#8221; should get you stared pretty easily. First prerequisite is to make sure you have xdebug installed [...]]]></description>
			<content:encoded><![CDATA[<p>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.</p>
<p>For all the <a href="http://netbeans.org/" target="_blank">Netbeans </a> users out there, if you don&#8217;t have debugging enabled, this little &#8220;how-to&#8221; should get you stared pretty easily.</p>
<p>First prerequisite is to make sure you have xdebug installed and enabled for PHP.</p>
<p>In the <strong>php.ini</strong> you should have the following settings:</p>
<pre class="brush: php; title: ; notranslate">
xdebug.remote_enable=1
xdebug.remote_mode=&quot;req&quot;
xdebug.remote_handler=&quot;dbgp&quot;
xdebug.remote_host=&quot;localhost&quot; #or try 0.0.0.0
xdebug.remote_port=9000
</pre>
<p>Make sure that the xdebug extension is enabled, of course.<br />
(Under the [XDebug] section of <strong>php.ini</strong>, zend_extension=[path to your php_xdebug lib]).<br />
Don&#8217;t forget to restart your web server ;)</p>
<p>Next we&#8217;ll install the Netbeans Fire Fox add-on.<br />
It can be downloaded from here: <a href="https://addons.mozilla.org/en-US/firefox/addon/easy-xdebug/" target="_blank">https://addons.mozilla.org/en-US/firefox/addon/easy-xdebug/</a><br />
As you can guess this means that FF should be your default browser, because it will need to open up once you start running the debugger.</p>
<p>Let&#8217;s switch to Netbeans, right click on the app of interest and navigate to &#8220;Properties&#8221;.<br />
In the project properties window select &#8220;Run configuration&#8221;.<br />
Project URL: http://yourhost.example.local/ (the local host name from which your app is running).<br />
Index File: index.php (easy enough).</p>
<p>Double check some options in Netbeans&#8230;<br />
Tools -> Options -> PHP tab<br />
&#8220;PHP Interpreter&#8221; should point to the correct location of your PHP executable.<br />
&#8220;Debugger Port&#8221; should be the same as the setting in your <strong>php.ini</strong> (xdebug.remote_port=9000)<br />
You might want to &#8220;uncheck&#8221; the &#8220;Stop at First Line&#8221; box. </p>
<p>This should be it, as far as the setup goes&#8230;</p>
<p>You can now run a quick test:<br />
Open <strong>app/webroot/index.php</strong>.<br />
Add a breakpoint at some line.<br />
(You might want to add <code>xdebug_break();</code> at the bottom of the file, just to be sure).<br />
Hit Ctrl+F5 (or whatever is the command on your OS to debug the project).</p>
<p>If all goes well FF should open up and you should see the code execution stop at the line where you&#8217;ve set the breakpont with some debug info in the Netbeans console.<br />
Congrats!</p>
<p>p.s. Setting up other IDE&#8217;s should be similar in the overall approach&#8230; but, as always, your mileage may vary.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/grVJoq99GIbsNBMCFVMkRZ20B6o/0/da"><img src="http://feedads.g.doubleclick.net/~a/grVJoq99GIbsNBMCFVMkRZ20B6o/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/grVJoq99GIbsNBMCFVMkRZ20B6o/1/da"><img src="http://feedads.g.doubleclick.net/~a/grVJoq99GIbsNBMCFVMkRZ20B6o/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=qHxx8A_u2kk:MqkripYiWyY:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=qHxx8A_u2kk:MqkripYiWyY:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=qHxx8A_u2kk:MqkripYiWyY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=qHxx8A_u2kk:MqkripYiWyY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:KwTdNBX3Jqk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=qHxx8A_u2kk:MqkripYiWyY:KwTdNBX3Jqk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=qHxx8A_u2kk:MqkripYiWyY:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/NutsAndBoltsOfCakephp/~4/qHxx8A_u2kk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nuts-and-bolts-of-cakephp.com/2011/07/21/setup-debugging-for-netbeans-cakephp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://nuts-and-bolts-of-cakephp.com/2011/07/21/setup-debugging-for-netbeans-cakephp/</feedburner:origLink></item>
		<item>
		<title>Offload read queries to a replica DB for better performance</title>
		<link>http://feedproxy.google.com/~r/NutsAndBoltsOfCakephp/~3/TOnDgXD5KBA/</link>
		<comments>http://nuts-and-bolts-of-cakephp.com/2011/07/01/offload-read-queries-to-a-replica-db-for-better-performance/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 15:27:59 +0000</pubDate>
		<dc:creator>teknoid</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[cakephp mysql performance]]></category>
		<category><![CDATA[cakephp optimization]]></category>
		<category><![CDATA[read only cakephp]]></category>
		<category><![CDATA[read only find]]></category>

		<guid isPermaLink="false">http://nuts-and-bolts-of-cakephp.com/?p=1260</guid>
		<description><![CDATA[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 have a cluster of databases, [...]]]></description>
			<content:encoded><![CDATA[<p>In most web application, which require a lot of <code>find()'s</code> 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 have a cluster of databases, but for the purpose of this example we&#8217;ll only use two data sources: &#8220;default&#8221; and &#8220;replica&#8221;.</p>
<p>Therefore our basic <strong>database.php</strong> will look something like this:</p>
<pre class="brush: php; title: ; notranslate">
public $default = array(
		'driver' =&gt; 'mysql',
		'persistent' =&gt; false,
		'host' =&gt; 'production.example.com',
		'login' =&gt; 'user',
		'password' =&gt; 'password',
		'database' =&gt; 'production',
		'prefix' =&gt; '',
		'encoding' =&gt; 'utf8'
	);

	public $replica = array(
		'driver' =&gt; 'mysql',
		'persistent' =&gt; false,
		'host' =&gt; 'readonly.example.com',
		'login' =&gt; 'user',
		'password' =&gt; 'password',
		'database' =&gt; 'readonly',
		'prefix' =&gt; '',
		'encoding' =&gt; 'utf8'
	);
</pre>
<p>This prepares our application to use two data sources, as needed.</p>
<p>Next, let&#8217;s imagine we have a good ol&#8217; blog and need to grab various information to build a list of posts.<br />
In our <code>Posts Controller</code>, we&#8217;ll have some method that gets the required information:</p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;Post-&gt;getListofPosts();
</pre>
<p>The method above will have to involve additional models to get all of the needed info (Author, Tag, (PostsTag for the join table), PostRating&#8230; and maybe a few other models). The point is that this is enough operations already to consider offloading them to our read-only DB server.</p>
<p>The actual process is quite simple.<br />
First, we&#8217;ll create a generic method in our <code>App Model</code>:</p>
<pre class="brush: php; title: ; notranslate">
protected function _switchDataSource($models, $datasource = 'default') {
		if (is_array($models)) {
			foreach ($models as $model) {
				ClassRegistry::init($model)-&gt;setDataSource($datasource);
			}
		}
	}
</pre>
<p>I hope this code is simple enough, but the implementation example is coming up&#8230;<br />
It&#8217;s worth to note that <code>ClassRegistry::init()</code> will cache your model information (object instance, to be more precise) in memory, therefore in a more complex case (where you might have multiple <code>find()'s</code>) the newly switched data source will persist until switched back. Therefore it is important to remember to &#8220;reset&#8221; your data source once you are done with the read operation(s).</p>
<p>Now, here&#8217;s the basic usage sample (this snippet would be inside of our <code>getListofPosts()</code> method):</p>
<pre class="brush: php; title: ; notranslate">
//let's switch our DS to replica
$this-&gt;_switchDataSource(array(
  'Post', 'PostsTag', 'Author', 'PostRating'
), 'replica');

//now we can execute our find with all of the above
//model data coming from the read-only DB
$posts = $this-&gt;find('all', array(
  'contain' =&gt; array(
  //include our models here
  ),
  'limit' =&gt; 35
));

//don't forget to switch the DS back to default
$this-&gt;_switchDataSource(array(
  'Post', 'PostsTag', 'Author', 'PostRating'
));

return $posts;
</pre>
<p>As you see the implementation is pretty simple. The only thing to keep in mind is that if you are getting some SQL errors, chances are you have not included all of the required models for the operation, the most common case is forgetting the join table model. To troubleshoot and see the results the <a href="https://github.com/cakephp/debug_kit/">debug kit</a> is very helpful, because it will show you which data source is being used to run a particular set of queries.<br />
Another hint, if you use the same set of models over and over you might as well assign them to a property in your model, so that if you need to add or change something you&#8217;d only do it in one place.<br />
Using our example we can modify the code like so:</p>
<pre class="brush: php; title: ; notranslate">
public $postQueryModels = array('Post', 'PostsTag', 'Author', 'PostRating');

....

$this-&gt;_switchDataSource($this-&gt;postQueryModels, 'replica');
</pre>

<p><a href="http://feedads.g.doubleclick.net/~a/aYE8qxopz8XqRygSBiTlc-nwqDM/0/da"><img src="http://feedads.g.doubleclick.net/~a/aYE8qxopz8XqRygSBiTlc-nwqDM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/aYE8qxopz8XqRygSBiTlc-nwqDM/1/da"><img src="http://feedads.g.doubleclick.net/~a/aYE8qxopz8XqRygSBiTlc-nwqDM/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=TOnDgXD5KBA:rtlFQgJsHsw:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=TOnDgXD5KBA:rtlFQgJsHsw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=TOnDgXD5KBA:rtlFQgJsHsw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=TOnDgXD5KBA:rtlFQgJsHsw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:KwTdNBX3Jqk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=TOnDgXD5KBA:rtlFQgJsHsw:KwTdNBX3Jqk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=TOnDgXD5KBA:rtlFQgJsHsw:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/NutsAndBoltsOfCakephp/~4/TOnDgXD5KBA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nuts-and-bolts-of-cakephp.com/2011/07/01/offload-read-queries-to-a-replica-db-for-better-performance/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://nuts-and-bolts-of-cakephp.com/2011/07/01/offload-read-queries-to-a-replica-db-for-better-performance/</feedburner:origLink></item>
		<item>
		<title>If you use UUID’s…</title>
		<link>http://feedproxy.google.com/~r/NutsAndBoltsOfCakephp/~3/6DiUlpq72YY/</link>
		<comments>http://nuts-and-bolts-of-cakephp.com/2011/06/22/if-you-use-uuids/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 18:58:32 +0000</pubDate>
		<dc:creator>teknoid</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[cakephp char36]]></category>
		<category><![CDATA[cakephp mysql]]></category>
		<category><![CDATA[cakephp uuid]]></category>
		<category><![CDATA[cakephp varchar36]]></category>
		<category><![CDATA[uuid]]></category>

		<guid isPermaLink="false">http://nuts-and-bolts-of-cakephp.com/?p=1256</guid>
		<description><![CDATA[Be extra careful to make sure that, according to convention, your &#8216;id&#8217; 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 complicated SELECT&#8217;s, which might require [...]]]></description>
			<content:encoded><![CDATA[<p>Be extra careful to make sure that, according to convention, your &#8216;id&#8217; column (or primary key) is:</p>
<p><code>char(36)</code> and <strong>never</strong> <code>varchar(36)</code></p>
<p>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 complicated SELECT&#8217;s, which might require some JOIN&#8217;s or calculations.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Yl-UsCSWBqh7haquDB4sNSS9LrE/0/da"><img src="http://feedads.g.doubleclick.net/~a/Yl-UsCSWBqh7haquDB4sNSS9LrE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Yl-UsCSWBqh7haquDB4sNSS9LrE/1/da"><img src="http://feedads.g.doubleclick.net/~a/Yl-UsCSWBqh7haquDB4sNSS9LrE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=6DiUlpq72YY:jeFkwu_hwKQ:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=6DiUlpq72YY:jeFkwu_hwKQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=6DiUlpq72YY:jeFkwu_hwKQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=6DiUlpq72YY:jeFkwu_hwKQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:KwTdNBX3Jqk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=6DiUlpq72YY:jeFkwu_hwKQ:KwTdNBX3Jqk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=6DiUlpq72YY:jeFkwu_hwKQ:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/NutsAndBoltsOfCakephp/~4/6DiUlpq72YY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nuts-and-bolts-of-cakephp.com/2011/06/22/if-you-use-uuids/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://nuts-and-bolts-of-cakephp.com/2011/06/22/if-you-use-uuids/</feedburner:origLink></item>
		<item>
		<title>find(‘first’)… gotcha</title>
		<link>http://feedproxy.google.com/~r/NutsAndBoltsOfCakephp/~3/Na8Nwt-X9OY/</link>
		<comments>http://nuts-and-bolts-of-cakephp.com/2011/05/16/findfirst-gotcha/#comments</comments>
		<pubDate>Mon, 16 May 2011 15:06:13 +0000</pubDate>
		<dc:creator>teknoid</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[cakephp find]]></category>
		<category><![CDATA[cakephp find('first')]]></category>
		<category><![CDATA[find conditions]]></category>
		<category><![CDATA[find('first')]]></category>

		<guid isPermaLink="false">http://nuts-and-bolts-of-cakephp.com/?p=1249</guid>
		<description><![CDATA[Just a simple tip&#8230; Here&#8217;s a typical find() example: 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: &#8216;condition&#8217; instead of &#8216;conditions&#8217;. Moral of the story is that find('first') can be a little tricky and misleading [...]]]></description>
			<content:encoded><![CDATA[<p>Just a simple tip&#8230;</p>
<p>Here&#8217;s a typical <code>find()</code> example:</p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;Post-&gt;find('first', array('condition' =&gt; array('id' =&gt; 5)));
</pre>
<p>Why does it return me the post with ID = 1, rather than ID = 5?</p>
<p>Of course, a careful reader spotted the spelling issue in the key:<br />
&#8216;condition&#8217; instead of &#8216;conditions&#8217;.</p>
<p>Moral of the story is that <code>find('first')</code> can be a little tricky and misleading and if you are getting an unexpected result be sure to double-check your implementation.</p>
<p><code>find('first', 'blah');</code></p>

<p><a href="http://feedads.g.doubleclick.net/~a/49T02JWvjyIFxYezkzM8JRhsS5I/0/da"><img src="http://feedads.g.doubleclick.net/~a/49T02JWvjyIFxYezkzM8JRhsS5I/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/49T02JWvjyIFxYezkzM8JRhsS5I/1/da"><img src="http://feedads.g.doubleclick.net/~a/49T02JWvjyIFxYezkzM8JRhsS5I/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=Na8Nwt-X9OY:8uNWhBvfC8o:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=Na8Nwt-X9OY:8uNWhBvfC8o:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=Na8Nwt-X9OY:8uNWhBvfC8o:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=Na8Nwt-X9OY:8uNWhBvfC8o:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:KwTdNBX3Jqk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=Na8Nwt-X9OY:8uNWhBvfC8o:KwTdNBX3Jqk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=Na8Nwt-X9OY:8uNWhBvfC8o:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/NutsAndBoltsOfCakephp/~4/Na8Nwt-X9OY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nuts-and-bolts-of-cakephp.com/2011/05/16/findfirst-gotcha/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://nuts-and-bolts-of-cakephp.com/2011/05/16/findfirst-gotcha/</feedburner:origLink></item>
		<item>
		<title>Installing membase/memcached</title>
		<link>http://feedproxy.google.com/~r/NutsAndBoltsOfCakephp/~3/vIH_fGs6Sbc/</link>
		<comments>http://nuts-and-bolts-of-cakephp.com/2011/04/21/installing-membasememcached/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 21:41:22 +0000</pubDate>
		<dc:creator>teknoid</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[cakephp membase]]></category>
		<category><![CDATA[cakephp memecached]]></category>
		<category><![CDATA[membase]]></category>

		<guid isPermaLink="false">http://nuts-and-bolts-of-cakephp.com/?p=1238</guid>
		<description><![CDATA[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, the installation is quite simple. [...]]]></description>
			<content:encoded><![CDATA[<p>These are instructions for getting membase/memcached installed in your local environment.<br />
(I was installing on windows so your setup might be a little different, but general approach is mostly the same).</p>
<p><strong>1. Download the membase server for your OS (community edition is the one you are after):</strong><br />
<a href="http://www.couchbase.com/downloads">http://www.couchbase.com/downloads</a></p>
<p>Once downloaded, the installation is quite simple. Just follow the prompts.<br />
After the server installation is complete, your default browser should open and you will be prompted to continue setting up the &#8220;cache bucket&#8221;.</p>
<p>Again, it is a simple step by step process. The only thing you&#8217;d want to make sure is that you select <strong>memcached</strong> bucket type.<br />
(This will be 100% compatible with any other default installation).</p>
<p><strong>2. Make sure you have memcache support enabled in your PHP install.</strong><br />
The easiest way to find out is to check the output of phpinfo(). Look for the &#8220;memcache&#8221; section.</p>
<p><strong>3. What to do if you don&#8217;t see the section mentioned above?</strong><br />
First, check your php.ini for: extension=php_memcache.dll (php_memcache.so, on *nix platforms).<br />
In some cases you just might need to uncomment the line above.</p>
<p>Next, you should have an entry for the php/memcached settings, it should look something like this:</p>
<p><code><br />
[Memcache]<br />
memcache.allow_failover = 1<br />
memcache.max_failover_attempts = 20<br />
memcache.chunk_size = 8192<br />
memcache.default_port = 11211<br />
</code></p>
<p>In my case the php_memcache.dll was missing, so I downloaded the appropriate version from:<br />
<a href="http://code.google.com/p/thinkam/downloads/detail?name=php_memcache-cvs-20090703-5.3-VC6-x86.zip&#038;can=2&#038;q=">http://code.google.com/p/thinkam/downloads/detail?name=php_memcache-cvs-20090703-5.3-VC6-x86.zip&#038;can=2&#038;q=</a></p>
<p>You&#8217;ll have to place the .dll or .so with the rest of your php extensions; if your are using XAMPP it will be somewhere like:<br />
c:\xampp\php\ext</p>
<p><strong>4. Configure cake</strong><br />
Open up <strong>app/config/core.php</strong> and scroll all the way down to the cache settings.<br />
Presuming you&#8217;ve installed everything with all defaults, all you&#8217;d have change is:<br />
<code>'engine' => 'File'  to 'engine' => 'Memcache'</code></p>
<p><strong>5. Restart your web server.</strong><br />
You might want to clear your model cache first, to be sure that cake doesn&#8217;t fall back on File caching if something isn&#8217;t configured properly.<br />
If all goes well, you should see no warnings, nothing should be written to the file system, and in your membase console (Monitor -> Data Buckets -> default) you should begin to see some activity.<br />
(Chart should be updated, as well you should see some records under TOP KEYS).</p>
<p>Congrats, you are now using memcached as your caching mechanism.</p>
<p>Good luck!</p>

<p><a href="http://feedads.g.doubleclick.net/~a/oaQq0MwA13xV3wMcd6_P2TxdsFs/0/da"><img src="http://feedads.g.doubleclick.net/~a/oaQq0MwA13xV3wMcd6_P2TxdsFs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/oaQq0MwA13xV3wMcd6_P2TxdsFs/1/da"><img src="http://feedads.g.doubleclick.net/~a/oaQq0MwA13xV3wMcd6_P2TxdsFs/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=vIH_fGs6Sbc:RoC7RVIcZdQ:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=vIH_fGs6Sbc:RoC7RVIcZdQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=vIH_fGs6Sbc:RoC7RVIcZdQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=vIH_fGs6Sbc:RoC7RVIcZdQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:KwTdNBX3Jqk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=vIH_fGs6Sbc:RoC7RVIcZdQ:KwTdNBX3Jqk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=vIH_fGs6Sbc:RoC7RVIcZdQ:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/NutsAndBoltsOfCakephp/~4/vIH_fGs6Sbc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nuts-and-bolts-of-cakephp.com/2011/04/21/installing-membasememcached/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://nuts-and-bolts-of-cakephp.com/2011/04/21/installing-membasememcached/</feedburner:origLink></item>
		<item>
		<title>Speed up your pagination with a simple hack…</title>
		<link>http://feedproxy.google.com/~r/NutsAndBoltsOfCakephp/~3/RohqH9xbOxo/</link>
		<comments>http://nuts-and-bolts-of-cakephp.com/2011/03/17/speed-up-your-pagination-with-a-simple-hack/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 16:30:03 +0000</pubDate>
		<dc:creator>teknoid</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[cakephp optimization]]></category>
		<category><![CDATA[cakephp paginator]]></category>
		<category><![CDATA[cakephp paginator speed up]]></category>
		<category><![CDATA[pagination]]></category>

		<guid isPermaLink="false">http://nuts-and-bolts-of-cakephp.com/?p=1231</guid>
		<description><![CDATA[Before I go into the example in this little post, let me just say that this situation won&#8217;t be applicable to everyone&#8230; But let&#8217;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; first to get the count [...]]]></description>
			<content:encoded><![CDATA[<p>Before I go into the example in this little post, let me just say that this situation won&#8217;t be applicable to everyone&#8230; </p>
<p>But let&#8217;s consider the following:<br />
We have a table with tens of thousands of records, that need to be paginated.</p>
<p>As you know, cake will execute two queries; first to get the count of total records, second to get the actual records.</p>
<p>The questions one might ask are:<br />
&#8220;Would any user really go through 5 thousand pages to find what they are looking for?&#8221;<br />
&#8220;If I bring the last 1,000 records wouldn&#8217;t that be enough for a vast majority of needs?&#8221;<br />
&#8220;How many pages in Google do you go through, when searching for something, before you give up?&#8221;<br />
&#8220;Is it not better to provide filters, or search tools to help your users narrow down the results to something manageable?&#8221;</p>
<p>If you&#8217;ve answered &#8220;Yes&#8221; to two or more questions, please consider the hack&#8230;</p>
<p>In your model, which needs to be paginated, do the following: </p>
<pre class="brush: php; title: ; notranslate">
public function paginateCount($conditions = null,
                                 $recursive = 0,
                                 $extra = array()) {
   return 1000;
}
</pre>
<p>Yep, we are overriding <code>paginateCount()</code> and simply returning 1,000 because we know that this will be the maximum amount of records that our paginator needs to know about.<br />
Depending on how complex the underlying query is (for example you might have JOIN&#8217;s or various conditions, which would usually need to be taken into the account in your typical count query), the above hack can dramatically increase the performance of your pagination.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/2299fhgByTeV4d5XeBC7YZV7gNo/0/da"><img src="http://feedads.g.doubleclick.net/~a/2299fhgByTeV4d5XeBC7YZV7gNo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/2299fhgByTeV4d5XeBC7YZV7gNo/1/da"><img src="http://feedads.g.doubleclick.net/~a/2299fhgByTeV4d5XeBC7YZV7gNo/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=RohqH9xbOxo:qbVVaVXOXRc:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=RohqH9xbOxo:qbVVaVXOXRc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=RohqH9xbOxo:qbVVaVXOXRc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=RohqH9xbOxo:qbVVaVXOXRc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:KwTdNBX3Jqk"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?i=RohqH9xbOxo:qbVVaVXOXRc:KwTdNBX3Jqk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?a=RohqH9xbOxo:qbVVaVXOXRc:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/NutsAndBoltsOfCakephp?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/NutsAndBoltsOfCakephp/~4/RohqH9xbOxo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nuts-and-bolts-of-cakephp.com/2011/03/17/speed-up-your-pagination-with-a-simple-hack/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://nuts-and-bolts-of-cakephp.com/2011/03/17/speed-up-your-pagination-with-a-simple-hack/</feedburner:origLink></item>
	</channel>
</rss>

