Happy Coding

If you want this article for CakePHP1.3 then click here.

Today we are going to learn how to print “hello world” in CakePHP2.x

CakePHP should be installed to apply this tutorial
if you don’t read “How to Install CakePHP” then you can visit now.

After installing CakePHP successfully you can read this tutorial to easily print “Hello World” in it.

Step 1:

Create UsersController.php file in your app/Controllers folder with following code.

Then open url in your localhost i.e. “localhost/cakefoldername/users”. By default it shows index() function. For using another function just change the name of function and open URL “localhost/cakefoldername/users/functionname” and it will work.

But This code will give error i.e. Table ‘Users’ not present. As for working of a Controller there is need of two other things by default i.e. Model for database connection and View for creating users view.

But here we are only printing Hello World then there is no need of both of them.

To remove table not found error just add following line to code:

It says that Controller doesn’t need any table. And removes table not found error.

Step 2 Removing View not found error

After correcting this error there is another error appears i.e. View not found. To overcome this error just add following line of code in index function:

Final Code:

Now our final code for UsersController.php is follows:

Download source code from here!!

Enjoy Coding.

If you have any issues comments are welcome.

Print Hello World in CakePHP 2.x without Model & View UG ArticlesCakePHPProgramming,,
Happy Coding If you want this article for CakePHP1.3 then click here. Today we are going to learn how to print “hello world” in CakePHP2.x CakePHP should be installed to apply this tutorial if you don’t read 'How to Install CakePHP' then you can visit now. After installing CakePHP successfully you can read this...
Happy Coding If you want this article for CakePHP1.3 then <a title="Hello WOrld Example in CakePHP1.3" href="http://www.grasphub.com/2013/01/print-hello-world-in-cakephp/">click here</a>. Today we are going to learn how to print “hello world” in CakePHP2.x CakePHP should be installed to apply this tutorial if you don’t read "<a title="Step by Step Guide to Install CakePHP" href="http://grasphub.com/step-by-step-guide-to-how-to-install-cakephp/">How to Install CakePHP</a>" then you can visit now. After installing CakePHP successfully you can read this tutorial to easily print "Hello World" in it. <strong>Step 1:</strong> Create UsersController.php file in your app/Controllers folder with following code. [crayon-59e899f529fc0384432179/] Then open url in your localhost i.e. "localhost/cakefoldername/users". By default it shows index() function. For using another function just change the name of function and open URL "localhost/cakefoldername/users/functionname" and it will work. But This code will give error i.e. Table 'Users' not present. As for working of a Controller there is need of two other things by default i.e. Model for database connection and View for creating users view. But here we are only printing Hello World then there is no need of both of them. To remove table not found error just add following line to code: [crayon-59e899f529fce350417228/] It says that Controller doesn't need any table. And removes table not found error. <strong>Step 2 Removing View not found error </strong> After correcting this error there is another error appears i.e. View not found. To overcome this error just add following line of code in index function: [crayon-59e899f529fd3933818826/] <strong>Final Code: </strong> Now our final code for UsersController.php is follows: [crayon-59e899f529fd6819767961/] <a href="http://www.grasphub.com/wp-content/uploads/2014/01/Hello-World.zip">Download source code from here!!</a> Enjoy Coding. If you have any issues comments are welcome.