FireStats error : FireStats database needs to be upgraded

Posts Tagged ‘hello world’

CakePHP - How to Run “Hello World” Program

Thursday, May 15th, 2008

I found that, novice programmers always face problem while trying to run CakePHP for the first time. So, here I’m describing a “Hello World” program in CakePHP.

1. First download the CakePHP from http://www.cakephp.org. You can download Stable: 1.1.19.6305 package or Beta: 1.2.0.6311 package.

2. Make a folder in your htdocs folder named “hello” and unzip the CakePHP package in that folder. Your files and folders will be like:

htdocs/hello
           /app
           /cake
           /docs
           /vendors
           /index.php
           .htaccess

3. Now copy app_controller.php file from .\cake\libs\controller\app_controller.php to .\app folder (.\app\app_controller.php).

4. Copy .\cake\libs\model\app_model.php to .\app folder (.\app\app_model.php).

5. Make a controller hello_controller.php in .\app\controllers\. Content of this controller.

<?php

class HelloController extends AppController {
  function index () {}
  function show () {
    $this->set('test', 'Hello World');
  }
}
?>

5. Make a model hello.php in .\app\models\. Content of this model.

<?php

class Hello extends AppModel {

  function index () { }
}
?>

6. Create a folder “hello” in .\app\views\. Then make a view file “show.ctp”. Content of this file.

<html>
<head><title>Hello World Program</title>
<head>
<body>
<h1><?php echo $test; ?></h1>
</body>
</html>


7. Open database.php in .\app\config\ folder and provide login, password, database etc. as your settings. Be sure that you have a table named “hello” in your provided database.

8. Enable mod_rewrite in your httpd.conf file. Uncomment (remove #).

LoadModule rewrite_module modules/mod_rewrite.so

Then restart your apache service.

Now you are ready to run this program. http://localhost/hello/hello/show

It will show “Hello World” in your browser.