Installing CakePHP

October 10, 2008 at 6:10 pm (CakePHP) (, , , )

Over the past few weeks I’ve been getting in grip with CakePHP. Actually it all started with a PHP framework that I wanted to build for my company. CMSs like Joomla, Drupal et al were fine but they were after all, CMS, too bulky and cumbersome. I wanted a framework that I could use for every project of mine. I looked into Ruby on Rails, but I didn’t want to leave PHP and soon I found out a long list of PHP frameworks that had copied the MVC features of Rails. And the first framework I looked into was CakePHP. The idea of Rails with PHP. Simply great. 

There were other options too, Symfony (admittedly it is better than CakePHP, but I couldn’t stand all those commands) and Zend. But for better or for worse, I’ve decided to stick with Cake and the lovely verb “Baking”.

Actually CakePHP is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. Using commonly known design patterns like MVC and ORMwithin the convention over configuration paradigm, CakePHP reduces development costs and helps developers write less code. For more lowdown go to Cake’s official website. 

As for this post, this actually tells you how to install CakePHP in Windows.

 

Downloading and Installing

Go to CakePHP’s site and download the latest version. I gather there are 2 versions currently, 1.1 and 1.2. Version 1.2 is in a pre-beta stage and has limited documentation and therefore downloading stable version 1.1 sounds a better idea. Go to the download page and grab the 1.1 zip file. Extract the files to a folder in your local web server (I gather you’ve got a web server up and ready with PHP and MySQL as well. If you have not done that then stop reading this post rightaway and download yourself XAMPP and install it) . Rename the folder to some easy name, I named mine simply cakephp. Inside you will have a number of folders and files including “app”, “cake”, “docs”, “vendors”, “.htaccess” and “index.php”.

 

Mod_Rewrite

Just a quick note on mod_rewrite, if you have installed Xampp as your local server or use Apache then its best if you enable mod_rewrite, simply open the “httpd.conf” file located at “C:\program files\xampp\apache\conf” and uncomment the following line by removing the ‘#’ symbol:

#LoadModule rewrite_module modules/mod_rewrite.so  

After which you need to restart your Apache webserver.

And now to see if you’ve got Cake installed properly, point to its link in your local web browser

 

http://localhost/cakephp/

You should in all probability see this screen

 

Cake PHP successful installation

Cake PHP successful installation

And if you dont, by that I mean if you see a funny looking screen with no colors and no CSS effects, then you’ve got problem mate and that most probably is with the mod_rewrite

(And by the way make sure, you’ve read CakePHP’s manual first and its requirements and do check the version of Apache, PHP and MySQL that your XAMPP carries)

For Vista users, disabling the UAC (Users Access Control is a good idea if you want to have your web directory in its default location (C:\Program Files\). To disable (or enable) UAC run msconfig and check Tools tab.

Changing the Security.salt Value

When a session is initialized, the server groups a set of requests together using a session ID, a database, or a cookie. Whatever the method, the idea behind the session is that the server can maintain a pseudoconnection with the user, even though the communication could get interrupted along the way. You’ve run into this when you’ve logged into your web-based e-mail account or some similar web service. The site application knows that you’re logged in and maintains that status until you log out or a certain length of inactivity transpires.

Luckily, Cake makes session handling easy. But you need to make sure that its session string is secure. You wouldn’t want any users to toy with the session handling in an effort to break into your applications.

To add some security to the session variables, open the app/config/core.php file, and locate line 153, or thereabouts. You’ll find a line that looks like this:

Configure::write(‘Security.salt’, ‘DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi’);

This line is how Cake writes definitions. Rather than use the PHP define() function, Cake’s core configuration uses the Configure::write() function to better manage global variables. Here, the Cake core uses the Security.salt definition for creating hashes and other
session variables.

Because that funky line of characters comes with Cake, everyone who uses Cake has the
same session string. Let’s change the second portion, the character string, to something
unique. Go ahead and fill in any alphanumeric string, about 40 characters in length, and paste
it here. I ended up with this:

Configure::write(‘Security.salt’, ‘wihaamtnaortedyooiundgoainnygthheirnegqzwxecrvtbyn’);

Now Cake has a salt value for when it needs to run any security configurations and hashing
that aren’t the default value.

Advertisements

Permalink Leave a Comment

Internal Error 2739 in Vista

October 7, 2008 at 9:09 am (technology) (, , , , )

While trying to install Open Worbench in Windows Vista, I came across this annoying problem. Every time I tried to run the installer I kept getting “internal error 2739” message and the installation process would terminate. At first I thought the setup file itself was corrupt. But on enabling MSI logging feature I learned that 2739 was MSI error code for “Could not access JavaScript runtime for custom action”. So I tried reinstalling jscript.dll.

cd c:\windows\system32
regsvr32 jscript.dll   

and it worked. 😉   

Note: For users running Vista x64, you need to reregister different version of jscript.dll file, the one that is in the WINDOWS\SysWOW64 folder
cd c:\Windows\SysWow64
regsvr32 jscript.dll

Permalink Leave a Comment