Skip to content
Adam Patterson edited this page Dec 18, 2012 · 1 revision

Your First App

OK, first off this isn't going to be a real application. We are just doing this to help you get a better feel of Dingo. All we want our application to do is display the words Hello, World! to the screen.

Configure The Home Page

Assuming you have already followed the installation procedures we can get started. Open up application/config/development/routes.php. The file should look something like this:

<?php if(!defined("DINGO")){die("External Access to File Denied");}

// Default Route
route::set('default_route','main/test');

Just ignore the very first line (the one with <?php at the beginning). All the first line does is prevent people from viewing info inside the file from their web browser.

"default_route" is the home page for your application. So when someone visits your home page (EX: www.yoursite.com) they will see the default page. Change the default route to hello/world, so your code should now look like this:

<?php if(!defined("DINGO")){die("External Access to File Denied");}

// Default Route
route::set('default_route','hello/world');

The hello portion of the default route tells your application what controller to use. In this case it tells us to use the 'hello' controller. The second portion, world, tells your application what function to run from that controller.

So basically, this tells your application to open up application/controllers/hello.php and run the world() function from the `hello_controller class.

Create The Controller

Create the file application/controllers/hello.php and open it up with your text editor. Add the following PHP class to the file:

<?php

class hello_controller
{

}

Now add the function world() to our new page controller class.

<?php

	class hello_controller
{
   public function world()
	{
   		echo 'Hello, World!';
	}
}

That's it. If you visit your application's root with your web browser you should see the words 'Hello, World!' on your screen.

Clone this wiki locally