Tuesday, November 10, 2009

CakePHP - Post Installation Work

So, you have installed CakePHP and you have seen the welcome screen.


Now point your browser to:
http://caketest.local/


Step: 1


The welcome screen says:
Please change the value of 'Security.salt' in app/config/core.php to a salt value specific to your application [CORE\cake\libs\debugger.php, line 557]




It is rather simple to get rid of this message.


Locate the file core.php under app/config folder.


Got it? Okay.


Change the default string of Security.salt value (something like 'EYhF23b0rvJFIxgx2GuvoUuBWwvniR2G0FgaC9mi') to whatever you want.  (I used 'EYhF23b0rvJFIxgx2' to replace the default string.)


And it was done. I could get rid of the first message. Hopefully, you have also got rid of that message.


Step: 2
The next message says:


Your tmp directory is writable.


In my case, I did not have any problem as my tmp directory was really writable. If you are trying it in a web server, you might have some problem.  And unfortunately if you have any problem, you can fix it by granting necessary permissions to your tmp directory.


Step: 3 
The next message says:
Your database configuration file is NOT present.
The message also says what should be done. 
Rename config/database.php.default to config/database.php


Okay. I did it. Simply follow that, i.e., rename the config/database.php.default to config/database.php.
Point your browser to:
http://caketest.local/
You can see that message has changed to give you a more friendly message:
Your database configuration file is present.
Let's move on to the next step.


Step: 4
The next message says:
Cake is NOT able to connect to the database.
For this you can't put blame on CakePHP. You need to configure your database configuration file. This is the same file we have just renamed - database.php. 


Look at that file closely. There is a class ('DATABASE_CONFIG') defined in it. Take a look inside the class. There is a member variable ($default) inside that class, which is an array itself! Do not be afraid. Simply go ahead reading.  I have marked the things you need to set with red color. Change the settings to match your database configuration. 


var $default = array(
'driver' => 'mysql',
'persistent' => false,

'host' => 'localhost',           /* I do not think you need to change it on most occasion. If it is anything   different other than 'localhost', then replace 'localhost' with the appropriate value, which you should know. */

'login' => 'admin', /* Replace 'admin' with your database username */

'password' => 'mypass', /* Replace 'mypass' with your database password */

'database' => 'caketest', /* Replace 'caketest' with your database name*/

'prefix' => '', /* This is to set table prefix. I'm not going to use any table prefic, so, it will be empty. */
);



Now point your browser to:
http://caketest.local


You can see a relieving message:
Cake is able to connect to the database.

So, I have done it!

I have downloaded, installed and run CakePHP. Further, I have made necessary changes to connect Cake (This is an abbreviation of CakePHP) to my mySQL database!

I hope you have come up to this point without much difficulty. In any case, if you have problem coming up to this point, just try everything from scratch. Install, change settings, follow step 1 - 4, and you should be able to have the same fun as I have right now.

Cheers! Let's be happy!

Not so much really. We need to make some more changes to make it look like my website. I'll do it in my next post.

No comments: