Orchid mvc framework tutorial : Basic example showing how to write a simple hello world application
Posted on | March 22, 2008 |
Originally from orchid blog at: http://orchid.phpxperts.net/2008/03/18/creating-a-basic-app-with-orchid/
Ok, lets try to create baby out of orchid
Take her at your place for date:
Copy the orchid folder to a location of choice where you like to host the app.
Make sure she is vergin
There should not be any app folder inside the orchid folder. If any, remove it.
Get inside of her, make her move…
Open up a console, go to the orchid directory. run:
$php cli.php skeleton test
You will find a new folder named app is created in orchid directory.
The last drop….
run the following command:
$php cli.php controller main
Bingo.. orchid is a very good mother and wont take 9 months to create a baby. You can see your baby at:
http://localhost/learn/test/orchidframework/index.php?main
Don’t forget to change the url as required for your setup.
Examining the baby:
in orchid/app/controllers folder a new file is created named main.php
and two more files in orchid/app/views/main/ folder naming base.php and hello.php.
What they do is really simple and easy to understand.
Here is the controller file content:
class main extends controller
{
function base()
{
$this->view->set(”name”,’main’);
}function hello()
{
$this->view->set(”param1″,’World’);
}
}
and hello.php and base.php are normal php files.
http://localhost/learn/test/orchidframework/index.php?main
This line executes the base method of the controller named main. ‘Base’ method is called implicitly if no explicit method is asked for.
and http://localhost/learn/test/orchidframework/index.php?main/hello
calls the hello method of the controller main.
Simple, eh ?
Just one more thing, you can pass values to the view from controller. Look at the hello method once again.
$this->view->set(’param1′,’world’);
And here how the param1 is used in hello.php
Hello <?=$param1;?>
Orchid’s baby is really smart, right ?!!
Cheers ![]()
Comments
Leave a Reply