Sunday, October 2, 2011

Installing Cakephp on Your Local Server

Today, I'm going to teach you how to install cakephp on your local server. This way, it saves you alot of time in coding and debugging your application compared to the online approach. This can also be useful if you or your team uses Git or SVN or any other repository services.

Requirements:
  • Cakephp Package - download the cakephp framework here. You can choose what version you want to download there but the latest the better, as it has the most bug fixes compared to the earlier versions.
  • Local Server - this is where your cake app will reside. There are some local servers you can download on the internet which already comes with PHP, MySQL, and Apache. The popular local testing servers are Wamp and Xampp.
  • PHP IDE - since cakephp is using the PHP programming language, you need a PHP IDE or PHP editor.   You can use a simple text editor like notepad but I recommend you use an IDE as it has alot of features which you can't see on a text editor. I use PhpDesigner7 and Notepad++.
  • Browser - I prefer Mozilla Firefox and Google Chrome.


Setting it up now:
  1. Extract the Cakephp framework to "www" folder if your using Wamp and rename the folder to whatever you like.
  2. Now, if you renamed the cakephp folder to "cakephp", run this "http://localhost/cakephp" in your browser. You will see a page something like the image below:


The lines highlighted in green are OK. The yellow ones need some modification.

  • Please change value of 'Security.salt' in app/config/core.php: What this means is you have to open the file core.php under app/core folder in your cakephp folder. Inside the core.php file, find this line and change its value. See the image below(highlighted in yellow).
  • What I usually do with this is I use an md5 generator which can be found on the internet. Like this: http://www.miraclesalad.com/webtools/md5.php. You just have to enter a word you like and it will automatically convert it to its md5 value.Copy the converted value and paste it to value I highlighted above.
  • Same thing with the "Security.cipherSeed" but you don't have to use an md5 generator anymore, you just have to enter a numeric value on it. Similar to its default value.
  • The third yellow highlighted line is pretty obvious. You just have to rename config/database.php.default to config/database.php. After renaming it, open database.php and change the values of the following according to your database connection setting, see the image below.

After modifiying the files I've mentioned above. Refresh the page on your browser now. You will see the page like this:


Yes! It's all green now. You can now start building your app.
I hope this article helped you setup your first cakephp app.
On my next post, I will teach you how to make your first cakephp layout.

No comments:

Post a Comment