<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Flipflops.org &#187; bake</title>
	<atom:link href="http://www.flipflops.org/category/bake/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flipflops.org</link>
	<description>Flipflops.org is about web development and fairly conceptual art</description>
	<lastBuildDate>Tue, 31 Jan 2012 23:26:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>XAMPP and the PHP CLI</title>
		<link>http://www.flipflops.org/2008/07/27/xampp-and-the-php-cli/</link>
		<comments>http://www.flipflops.org/2008/07/27/xampp-and-the-php-cli/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 21:00:47 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[bake]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Things]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2008/07/27/xampp-and-the-php-cli/</guid>
		<description><![CDATA[Like a lot of people I do most of my development work on windows PC and locally run a web a server and database. Like a a lot of people I just downloaded and installed a server bundle. For the last few years I have used Apache2triad and it has generally been pretty painless, but [...]]]></description>
			<content:encoded><![CDATA[<p>Like a lot of people I do most of my development work on windows PC and locally run a web a server and database. Like a a lot of people I just downloaded and installed a server bundle. For the last few years I have used <a href="http://www.apache2traid.net">Apache2triad</a> and it has generally been pretty painless, but I&#8217;ve recently been forced to abandon it. Unfortunately the development seems to have been abandoned about 2 years ago.</p>
<p>The reason I abandoned Apache2triad was PHP versions &#8211; I wanted to do some work with <a href="http://code.google.com/apis/base/">Google Base</a> using the <a href="http://framework.zend.com/download/gdata">Zend Google Data Library</a> which required PHP 5.1.4+. </p>
<p>Looking around at the various bundles I decided to go with <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> &#8211; a lot of people seem to use it and it seems to get pretty good feedback. I won&#8217;t say the process was entirely painless (it took a couple of goes to get everything up and running) but eventually it all seemed OK.</p>
<p>The fun started when I decided to do a bit of <a href="http://book.cakephp.org/view/113/code-generation-with-bake">baking</a> (generating scaffolding code for my <a href="http://www.cakephp.org">CakePHP</a> app from a command line interface). Nothing worked.</p>
<p>Looking into it I discovered more than I wanted to know about the PHP Command Line Interface (CLI) which I had happily used for years with no idea it actually existed, having assumed it was just there as part of PHP.</p>
<p>After a lot googleing and a lot of trial and error I got it all working again and this is how I did it.</p>
<p>My environment is Windows XP Pro Service Pack 2 with XAMPP installed on E:/</p>
<ol>
<li>Downloaded the latest version of PHP and replaced the entire contents of  E:\xampp\php\.</li>
<li>Added to the E:\xampp\php to my environment PATH.</li>
</ol>
<p>At this stage PHP CLI wwas now working but there were nasty errors e.g. I was uanble to connect to MySQL from scripts. I discovered that this is because PHP CLI uses a different php.ini file to regular PHP.</p>
<p>To fix this I <strong>copied</strong> my php.ini from E:\xampp\apache\bin\php.ini (the default XAMPP ini file) to E:\xampp\php.</p>
<p>I then checked the PHP CLI again using php -v at a command prompt. There were now about 6 errors displayed, concerned with modules that could not be loaded or found. I believe that these concern modules just that aren&#8217;t meaningful in CLI mode. So I went through my new php.ini in E:\xampp\php and commented out the directives that were causing the errors until PHP CLI ran without errors.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2008/07/27/xampp-and-the-php-cli/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HABTM / Checkbox working example</title>
		<link>http://www.flipflops.org/2007/04/05/habtm-checkbox-working-example/</link>
		<comments>http://www.flipflops.org/2007/04/05/habtm-checkbox-working-example/#comments</comments>
		<pubDate>Thu, 05 Apr 2007 11:02:53 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[bake]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Web Things]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2007/04/05/habtm-checkbox-working-example/</guid>
		<description><![CDATA[Reading the CakePHP group messages, a lot of people seem to run into problems with creating HABTM relationships and changing from the default multipleSelect to using a series of checkboxes. In an app I was building I ran into a brick wall where I just wasn&#8217;t able to find out waht was wrong so I [...]]]></description>
			<content:encoded><![CDATA[<p>Reading the <a href="http://groups.google.com/group/cake-php?hl=en">CakePHP group</a> messages, a lot of people seem to run into problems with creating HABTM relationships and changing from the default multipleSelect to using a series of checkboxes. In an app I was building I ran into a brick wall where I just wasn&#8217;t able to find out waht was wrong so I just decided to bake a quick example that I could use as a reference.</p>
<p><strong>This is for Cake 1.1.x.x</strong></p>
<p>I used a slightly modified copy of the SQL from the <a href="http://manual.cakephp.org/chapter/models">manual</a> and used  <a href="http://bakery.cakephp.org/articles/view/294">Josh McFarren&#8217;s checkbox helper</a>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">--</span>
<span style="color: #808080; font-style: italic;">-- Table structure for table `posts`</span>
<span style="color: #808080; font-style: italic;">--</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`posts`</span> <span style="color: #66cc66;">&#40;</span>
  <span style="color: #ff0000;">`id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`title`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`body`</span> text<span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`created`</span> datetime <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`modified`</span> datetime <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`status`</span> tinyint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">TYPE</span><span style="color: #66cc66;">=</span>MyISAM;
&nbsp;
<span style="color: #808080; font-style: italic;">-- --------------------------------------------------------</span>
&nbsp;
<span style="color: #808080; font-style: italic;">--</span>
<span style="color: #808080; font-style: italic;">-- Table structure for table `posts_tags`</span>
<span style="color: #808080; font-style: italic;">--</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`posts_tags`</span> <span style="color: #66cc66;">&#40;</span>
  <span style="color: #ff0000;">`post_id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`tag_id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`post_id`</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">`tag_id`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">TYPE</span><span style="color: #66cc66;">=</span>MyISAM;
&nbsp;
<span style="color: #808080; font-style: italic;">-- --------------------------------------------------------</span>
&nbsp;
<span style="color: #808080; font-style: italic;">--</span>
<span style="color: #808080; font-style: italic;">-- Table structure for table `tags`</span>
<span style="color: #808080; font-style: italic;">--</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`tags`</span> <span style="color: #66cc66;">&#40;</span>
  <span style="color: #ff0000;">`id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`name`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">TYPE</span><span style="color: #66cc66;">=</span>MyISAM;</pre></td></tr></table></div>

<p>I have made two changes to the SQL above:</p>
<ol>
<li>Removed the user_id field in &#8216;posts&#8217; (to simplify the example)</li>
<li>Changed &#8216;tag&#8217; to &#8216;name&#8217; in &#8216;tags&#8217; &#8211; I changed this because generateList was not working and the $tags array geneated for the view did not contain the tag name &#8216;tag&#8217; &#8211; only the &#8216;tag_id&#8217; value.</li>
</ol>
<p>You can download my working example, it contains all of the files that I create in bake and the files added and changed to use the <a href="http://bakery.cakephp.org/articles/view/294">checkboxHelper</a>. To install the example:</p>
<ol>
<li>Bake a new application</li>
<li>Connect to database</li>
<li>Paste files from zip example to replace the newly baked files</li>
<li>Create database tables using the SQL</li>
</ol>
<p><a href="http://www.flipflops.org/example/habtm_checkbox_example.zip" title="HABTM_checkbox_example.zip">HABTM_checkbox_example.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2007/04/05/habtm-checkbox-working-example/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Session Error in Cake App</title>
		<link>http://www.flipflops.org/2007/04/03/session-error-in-cake-app/</link>
		<comments>http://www.flipflops.org/2007/04/03/session-error-in-cake-app/#comments</comments>
		<pubDate>Tue, 03 Apr 2007 16:04:55 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[bake]]></category>
		<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2007/04/03/session-error-in-cake-app/</guid>
		<description><![CDATA[I have spent the past 24 hours pulling my hair out over a very odd error in a CakePHP application I have been developing. I had an app called training, so my directory structure looked like this (the training app was generated using bake) I had copied large amounts of code from another cake site [...]]]></description>
			<content:encoded><![CDATA[<p>I have spent the past 24 hours pulling my hair out over a very odd error in a<a href="http://www.cakephp.org"> CakePHP</a> application I have been developing.<br />
I had an app called training, so my directory structure looked like this (the training app was generated using bake)</p>
<p><img src="http://www.flipflops.org/wp-content/uploads/2007/04/trainingdb.gif" alt="Dreamweaver Screenshot" /></p>
<p>I had copied large amounts of code from another cake site that I am also developing including a simple login system to password protect the admin routes.</p>
<p>I noticed that as I was browsing the site and tried to login, I would login successfully into the admin area and then as soon as I tried to access any controller method in the admin section I would be logged out.</p>
<p>I echoed all my POST and SESSION variables to the screen in the layout using:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;pre&gt;
   <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
   <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

</pre>
<p>So I knew that I was being logged in successfully.</p>
<p><img src="http://www.flipflops.org/wp-content/uploads/2007/04/session.gif" alt="Session Screenshot" /></p>
<p>When I tried to access another controller action e.g. /admin/courses/index I would be logged out and asked to login again. Eventually I noticed that when I logged in I was being redirected to /training/admin/homes/index instead of the expected /admin/homes/index which is why I was being logged out.</p>
<p>I examined all the releveant files in my working application and my broken one and discovered that the only difference was that the working application was called /app/ and the broken one was called /training/ I re-named training to /app/ uploaded the site and it all worked again.</p>
<p>I am not sure at the moment whether this is the result of something I have misunderstood or if it is a bug, anyway I'll stick it on trac when I get the chance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2007/04/03/session-error-in-cake-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Bake to Work</title>
		<link>http://www.flipflops.org/2007/02/28/getting-bake-to-work/</link>
		<comments>http://www.flipflops.org/2007/02/28/getting-bake-to-work/#comments</comments>
		<pubDate>Wed, 28 Feb 2007 13:57:32 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[bake]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Web Things]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2007/02/28/getting-bake-to-work/</guid>
		<description><![CDATA[A really powerful feature of CakePHP is bake &#8211;  a script located at  /cake/scripts/bake.php &#8211; it is similar in function to the Ruby on Rails Scaffold application &#8211; it is a command line programme that can generate outline or scaffolding code to carry out simple CRUD operations, based solely on your database structure. I have had quite [...]]]></description>
			<content:encoded><![CDATA[<p>A really powerful feature of <a href="http://www.cakephp.org">CakePHP</a> is bake &#8211;  a script located at  /cake/scripts/bake.php &#8211; it is similar in function to the <a href="http://www.rubyonrails.org/">Ruby on Rails</a> Scaffold application &#8211; it is a command line programme that can generate outline or scaffolding code to carry out simple CRUD operations, based solely on your database structure.</p>
<p>I have had quite a few problems getting Bake to work reliably, but persevere because it is worth it. I have been developing on a PC running XP Pro and <a href="http://apache2triad.net/">Apache2Triad</a> 2.0.55</p>
<p><strong>On windows there seems to be a bit of an issue with paths and in order to do any baking on an existing project you need to specify the full paths.</strong></p>
<p>[I use the <a href="http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx">Command Window Here</a>  Power Toy for Win XP which makes it easy to get the command prompt to the right place.]</p>
<h3>To create a new cake application</h3>
<ol>
<li>Navigate to <code>\cake\scripts\</code> and open the command prompt.</li>
<li><code>php bake.php -app name_of_application</code></li>
<li>follow the onscreen instructions&#8230;</li>
</ol>
<p>For Example: To create a new application called Flamingo:</p>
<p><code>php bake.php -app flamingo</code></p>
<p><img src="http://www.flipflops.org/wp-content/uploads/2007/02/bake2.gif" alt="bake" /></p>
<p>As you can see bake asks you if its ok to create a skeleton application on the path specified.</p>
<h3>How to bake inside an existing application</h3>
<p>If you want to bake inside an existing application, from the Cake tutorials and articles, it appears that you should be able to just type: <code>php bake.php -app flamingo</code> again, unfortunately this doesn&#8217;t work. Instead you get the following message.</p>
<p><img src="http://www.flipflops.org/wp-content/uploads/2007/02/bake3.gif" alt="how not to bake" /></p>
<p>What you actually need to type is something that includes the full path to your new cake application, something like:</p>
<p><code>php bake.php -app D:\apache2triad\htdocs\ctest\public_html\flamingo</code></p>
<p>If you already have a database structure you will see something like this:</p>
<p><img src="http://www.flipflops.org/wp-content/uploads/2007/02/bake5.gif" alt="Let’s bake" /></p>
<p>If you don&#8217;t yet have a database setup you will be prompted for connection details like this:</p>
<p><img src="http://www.flipflops.org/wp-content/uploads/2007/02/bake4.gif" alt="bake - no database" /></p>
<p><em><strong>Happy Baking</strong></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2007/02/28/getting-bake-to-work/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

