CakePHP – How to Run “Hello World” Program
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 .cakelibscontrollerapp_controller.php to .app folder (.appapp_controller.php).
4. Copy .cakelibsmodelapp_model.php to .app folder (.appapp_model.php).
5. Make a controller hello_controller.php in .appcontrollers. 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 .appmodels. Content of this model.
<?php class Hello extends AppModel { function index () { } } ?>
6. Create a folder “hello” in .appviews. 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 .appconfig 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.
Tags: CakePHP, hello world, PHP, Programming, tutorial






May 26th, 2008 at 2:19 am
May 26th, 2008 at 2:26 pm
August 30th, 2008 at 12:46 pm
August 31st, 2008 at 11:30 am