Introduction and installation of cakePHP

Introduction and installation of cakePHP

Hi, This is my first post for cakePHP.CakePHP is framework that makes building web applications simpler, faster and require less code.

Here how we use it.(this post is for 1.2.x,1.3.x)
Download CakePHP
https://github.com/cakephp/cakephp/tags

unzip the package to root folder.

setp to installation
1) Create a database

2) Edit database setting (rename following file to database.php)
Path: app/config/database.php.default


var $default = array('driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'username',
'password' => 'password',
'database' => 'datapasename',
'prefix' => '');

3) edit core file (app/config/core.php),Change the value of security.salt


Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');

4)Create a app controller file (app/app_controller.php)


class AppController extends Controller
{
var $helpers = array('Form','Html','Javascript');
var $components = array();

function beforeFilter()
{

}
}

5) Create pages controller (app/controllers/pages_controller.php)


class PagesController extends AppController
{
var $name = 'Pages';
var $uses = array();
var $components = array();
function display()
{

}
}

6) Create layout (app/view/pages/layout/default.ctp)


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $title_for_layout?></title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<!-- Include external files and scripts here (See HTML helper for more info.) -->
<?php echo $scripts_for_layout ?>
</head>
<body>

<!-- If you'd like some sort of menu to
show up on all of your views, include it here -->
<div id="header">
<div id="menu">...</div>
</div>

<!-- Here's where I want my views to be displayed -->
<?php echo $content_for_layout ?>

<!-- Add a footer to each displayed page -->
<div id="footer">...</div>

</body>
</html>

7) Create view for page (app/view/pages/display.ctp)


<h3>Welcome</h3><br />
<p>This is display page.</p>

8)Installation complete ! Enjoy

Atul Kumar
atu@atulk.in
atulk.in