<?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>Promet CakePHP Source &#187; applications</title>
	<atom:link href="http://cakephp.prometsupport.com/tag/applications/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakephp.prometsupport.com</link>
	<description></description>
	<lastBuildDate>Mon, 23 Feb 2009 08:03:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How to Bake a New Project in CakePhp</title>
		<link>http://cakephp.prometsupport.com/2008/learn-how-to-bake-cakephp-app/</link>
		<comments>http://cakephp.prometsupport.com/2008/learn-how-to-bake-cakephp-app/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 13:35:50 +0000</pubDate>
		<dc:creator>rachel</dc:creator>
				<category><![CDATA[CakePHP 1.2]]></category>
		<category><![CDATA[Tips & Tutorials]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[bake]]></category>

		<guid isPermaLink="false">http://cakephp.prometsupport.com/?p=103</guid>
		<description><![CDATA[div.block {margin: .5em 25px; background-color: #efefef; padding: .5em;} div.note {margin: .5em 25px; background-color: #fffbcc; padding: .5em;} I use bake to start any project of mine and therefore doesn&#8217;t mean that using it produces a complete app unless you only want a CRUD application. This tutorial is intended for beginners in cakephp. It is still recommended [...]]]></description>
			<content:encoded><![CDATA[<style>
div.block {margin: .5em 25px; background-color: #efefef; padding: .5em;}
div.note {margin: .5em 25px; background-color: #fffbcc; padding: .5em;}
</style>
<p>I use bake to start any project of mine and therefore doesn&#8217;t mean that using it produces a complete app unless you only want a CRUD application.</p>
<p>This tutorial is intended for beginners in cakephp. It is still recommended that you look at the <a href="http://book.cakephp.org/view/219/Blog">blog tutorial</a> in cakephp manual because it has a more complete introduction for the framework. </p>
<p>Take note that I am using the <a rel="nofollow" href="http://cakeforge.org/frs/?group_id=23&#038;release_id=426">Cakephp 1.2.0.7692 RC3</a> in demonstrating this little project because it is the latest release as of this writing. </p>
<h2>What to do and what do we need to begin?</h2>
<p>To start off, we need a project. I opted a mini-library application which consists of</p>
<div class="block">Books<br />
Authors<br />
Book reviews by users
</div>
<p><span id="more-103"></span><br />
The mini-library will store different books. Each books can have one or more authors and one or more reviews created by users. So we will have the following tables</p>
<div class="block">authors<br />
books<br />
books_authors<br />
book_reviews<br />
users
</div>
<p>And they have the following relationships:</p>
<div class="block">books can have many authors<br />
authors can have many books<br />
books can have many reviews<br />
users can have many reviews<br />
a review is owned by a book
</div>
<p><a href='http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cakedemo_1.sql'>Download the SQL</a> and create your database.</p>
<h2>Let&#8217;s start baking!</h2>
<p>Since our topic is about baking, we will maximize the use of cake CLI. First, setup your environment so that it will accept the cake command. For Ubuntu users, it is already available in synaptic or use apt-get</p>
<p><code lang="bash">sudo apt-get install cakephp1.2-scripts</code></p>
<p>For windows users, I used this <a rel="nofollow" href="http://www.webdevelopment2.com/cakephp-bake-baking-models-controllers-views-cakephp-12/">tutorial for setting up Windows</a>.</p>
<div class="note">The following steps is done in Windows so I cannot guarantee the result will be the same in Ubuntu.</div>
<p>Once you have setup your environment, everything is just easy. I do not think I even need to tell you what you need to do but I still will since I already started it:P</p>
<p>You just need to remember this steps:</p>
<ol>
<li>Create a project. This creates all the files and directories under the /app directory</li>
<li>Configure database.php. We will do that using the command line</li>
<li>Start creating your Models. As the blog tutorial mentioned, models are the bread and butter of cakephp.</li>
<li>Create your controllers </li>
<li>Finally, create your views</li>
<li>Check your new app!</li>
</ol>
<p>So let&#8217;s start doing something and stop talking eh? </p>
<p>Open your command line and go to your www directory or wherever you want to create your cakephp project. Do not yet create folder for this project. So in my case, my web directory is E:\www\. Type </p>
<p><code lang="bash">cake bake </code></p>
<p>It will ask you to create your project since it cannot find an existing one. </p>
<p><b>Step 1: Create project</b><br />
I created <em>mylibrary</em> project. Here is the output.</p>
<p><a href="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake1.png"><img src="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake1-300x181.png" alt="CakePhp bake step 1 - Create Project" title="cake_bake1" width="300" height="181" class="size-medium wp-image-121" /></a></p>
<p><b>Step 2: Configure database</b><br />
Then it will ask you to create your database config. In my example, my database name is <em>cakedemo_1</em>.</p>
<p><a href="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake2.png"><img src="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake2-300x247.png" alt="CakePhp bake step 2 - Configure database" title="cake_bake2" width="300" height="247" class="size-medium wp-image-122" /></a></p>
<p>And we&#8217;re done with the installation. If you will check your files, <em>mylibrary</em> folder is created in E:\www. <em>mylibrary</em> already contains all the necessary files and folders to start building your app. To check, go to <u>http://localhost/mylibrary</u>. </p>
<p><a href="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake3.png"><img src="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake3-300x145.png" alt="CakePhp bake step 3 - Installation result" title="cake_bake3" width="300" height="145" class="size-medium wp-image-123" /></a></p>
<p>Do we have the same result?</p>
<p>There were 3 things that happened here in the background. </p>
<ul>
<li>In mylibrary/app/config/core.php, the Security.salt was modified</li>
<li>mylibrary/app/config/database.php was created</li>
<li>In mylibrary/app/webroot/index.php, CAKE_CORE_INCLUDE_PATH was changed to the absolute path of your cake core library, in my case &#8220;E:www\minilib&#8221; because this is what I entered in my Path settings (remember this <a rel="nofollow" href="http://www.webdevelopment2.com/cakephp-bake-baking-models-controllers-views-cakephp-12/">tutorial</a>?) So with this, you have a <strong>centralized cakephp core library</strong>.</li>
</ul>
<p>There you have it, a new cakephp project! Let&#8217;s proceed.</p>
<p><b>Step 3: Create models, controllers and views</b><br />
Next step is to create our library application. Again, type <strong>cake bake</strong> in your command line. The <strong>Interactive Bake Shell</strong> will appear to ask for more directions. You must ofcourse create first your models, then controllers and finally views. Afterwards, you should have the following files like mine:</p>
<p><a href="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake4.png"><img src="http://cakephp.prometsupport.com/wp-content/uploads/2008/10/cake_bake4-129x300.png" alt="CakePhp Bake Step 3 - result" title="cake_bake4" width="129" height="300" class="size-medium wp-image-127" /></a></p>
<p>If you already have that, congratulations! Your done! <img src='http://cakephp.prometsupport.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Visit the Books page in <u>http://localhost/mylibrary/books/</u> to start adding your data.</p>
<p><strong>More tricks you can try out</strong><br />
There are also shortcuts if you only want to create models<br />
<code lang="bash">cake bake model</code></p>
<p>or controllers<br />
<code lang="bash">cake bake controller</code></p>
<p>or views<br />
<code lang="bash">cake bake view</code></p>
<p>For the next post, I&#8217;ll tackle how to set up different authentication components. Till next time. Happy Baking!</p>
]]></content:encoded>
			<wfw:commentRss>http://cakephp.prometsupport.com/2008/learn-how-to-bake-cakephp-app/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
