Hello World in CakePHP – 3 steps

  1. Download and set up CakePHP in your webroot. Stop reading further if you cant do it or you are not sure how to do it.
  2. Create a file named “helloworld_controller.php” in folder “cakephp/app/controllers/helloworld_controller.php” and paste following code in the file
    class HelloWorldController extends Controller {
    public $name = 'HelloWorld'; //Controller name, we need it.
    public $uses=null; //The example doesn't "use" any model.
    public $autoRender=false; //Do not render "automagically"
    public function index() {//The default action for a CakePHP controller
    echo __METHOD__;//This will print HelloWorld suffixed with some more info ;-)
  3. Point your browser to CakePHP installation on your server for example “http://localhost/cakephp/helloworld/”

Piece of cake… 🙂

Join the Conversation


  1. this is an incomplete echo world example
    why not using a view? following MVC principles

    => put sth to echo

    public function index() {} // can stay empty

    and I would use an array here:
    $var uses = array();

    now visit

    thats all…
    more correct then the version above.

  2. @mark, agreed to your point. But you still have to create a controller. I know in an MVC framework the purists will insist upon keeping view separate from controller. But as the title says, its simple 3 steps hello world example.

Leave a comment

Your email address will not be published. Required fields are marked *