Happy Coding

Today we are going to learn how to print “hello world” in CakePHP

CakePHP should be installed to apply this tutorial
if you don’t read previous tutorials then you can visit here.

Please ensure that you have ‘users’ table in database. Because CakePHP automatically check for tables with same name as controller. In this example we are using users_controller.php so it uses ‘users’ table for automatically. But in this application we don’t do anything with table.

Step 1:

Create users_controller.php in your app/controllers folder with following codeset.

<?php
class UsersController extends AppController
{
var $name='Users';
function index()
{
}
}
?>

We used function index() so we must create index.ctp file in view i.e. functions present in controller are the views present in view folder

Step 2 Create user.php in your app/models with following codeset

<?php
class User extends AppModel
{
var $name='User';
}
?>

Step 3 Now create the file which is viewed by users i.e. index.ctp because we used index() function in users_controller.php. It should have following codeset

<html>
<?php
echo "Hello World";
?>
</html>

These all steps are compulsary for this example to work it seems so complex , that for simple ‘Hello World’ we are doing so much effort but it is so useful in creating large applications and reduce the efforts of programmer.

Enjoy..!!

Print Hello World in CakePHP 1.3 UG Programming
Happy Coding Today we are going to learn how to print 'hello world' in CakePHP CakePHP should be installed to apply this tutorial if you don't read previous tutorials then you can visit here. Please ensure that you have 'users' table in database. Because CakePHP automatically check for tables with same name as...
Happy Coding Today we are going to learn how to print "hello world" in CakePHP CakePHP should be installed to apply this tutorial if you don't read previous tutorials then you can visit <a title="Step by Step guide to: How to install CakePHP" href="http://grasphub.com/step-by-step-guide-to-how-to-install-cakephp/">here</a>. Please ensure that you have 'users' table in database. Because CakePHP automatically check for tables with same name as controller. In this example we are using users_controller.php so it uses 'users' table for automatically. But in this application we don't do anything with table. <strong>Step 1:</strong> Create users_controller.php in your app/controllers folder with following codeset. <code><?php class UsersController extends AppController { var $name='Users'; function index() { } } ?></code> We used function index() so we must create index.ctp file in view i.e. functions present in controller are the views present in view folder <strong>Step 2 Create user.php in your app/models with following codeset</strong> <code><?php class User extends AppModel { var $name='User'; } ?></code> <strong>Step 3 Now create the file which is viewed by users i.e. index.ctp because we used index() function in users_controller.php. It should have following codeset</strong> <code> <html> <?php echo "Hello World"; ?> </html></code> These all steps are compulsary for this example to work it seems so complex , that for simple 'Hello World' we are doing so much effort but it is so useful in creating large applications and reduce the efforts of programmer. Enjoy..!!