today i was planning to start the documentation of orchid framework for the rest of us(?). so this one is the first installment of this series. you will find small tutorials everyday. just stick with the series and you will see how far we can fly you. time to get high
[please note that the text in this series will be all-small cap]
getting started with orchid
orchid is a small framework with bare necessities to kick start developing killer php web applications. this framework is not flooded with unnecessary features and libraries. it only contains the essential helpers and libraries to boost up your development, not slowing it down. orchid features a very short learning curve, which will keep you trouble free. small footprint and excellent profile will be your first choice, which you will definitely realize once you start realizing the power that orchid brings in your hand. long story short, orchid is the next framework going to rock.
you can checkout orchid from it’s subversion repository
svn checkout http://orchidframework.googlecode.com/svn/trunk/ orchidframework
orchid comes pre equipped with excellent configuration directives in a config file, which we will focus in details in the upcoming tutorials. for now lets just start as is.
to create your first application, we need to create a folder named “app” inside the orchidframework directory. after you create that, there will be three directories named app, core and tests.
in orchid, controllers reside in app/controllers directory. views (templates) reside in app/views/controller_name/ directory, which means if the name of your controller is “blog”, all your views remains in app/views/blog/ directory. lets create our first controller named “talk”. the controller file will be app/controllers/talk.php.
a controller in orchid is a normal php class file which extends the base controller class. all the public methods in a controller class are considered as action. a method named “base” is the primary action for all the controller in orchid. and for now, this is all the information you need to create your first controller in orchid.
lets write a sample action in our controller, named “base”
<?php
/**
* the source file is app/controllers/talk.php
*/
class talk extends controller
{
public function base()
{
echo "hello";
}
}
?>
now you can run this controller by pointing your browser to the following location. i considered that you have hosted orchid in your document root (i.e /var/www/orchid)
http://localhost/orchid/talk
whoops, what have we done wrong? why do we get an error?
we are seeing this error because we didnt write our view (or template, whatever you call it) yet. and this is not a good coding practice to output anthing directly from your controller. whatever the size of the output, you should display it by passing the data to a view first. this will ensure the consistency of your project through out the application. orchid is flexible, but keeping the word “flexibility with responsibility”
lets write the view file, named “<i>base.php</i>” which will reside in app/views/talk/ directory.
<?//the source file is app/views/talk/base.php?> <?=$talkings;?>
so where from do we get the variable named $talkings? dont worry, you will have to pass it to the view from your controller. in fact through out your application you have to pass all the data to a view from the controller in almost every mvc framework and orchid is not the exception in this case. lets re write the controller
<?php
/**
* the source file is app/controllers/talk.php
*/
class talk extends controller
{
public function base()
{
$this->setViewParam("talkings","hello world");
}
}
?>
now you will see the output “hello world” as output when you point your browser to http://localhost/orchid/talk
orchid is very flexible and if you need to raw output (for example after a ajax request) some content from your controller, you can even do that. orchid wont restrict you from not doing so, but what we really said is that for good coding you should follow this guideline.
so that’s it. getting started in orchid wont take more than 5 minutes and that is where the blessings of using a framework is in. in next tutorial we will learn how to use a model in orchid.
11 Responses
Shahid
April 6th, 2008 at 6:42 pm
1great start!!!
ranacse05
April 6th, 2008 at 6:49 pm
2Hmm .Very much helpful but we want more like CI.
PHP Coding School » Blog Archive » php tutorial [2008-04-06 19:44:17]
April 6th, 2008 at 7:53 pm
3[…] part 1: getting started with orchid By Hasin Hayder so that’s it. getting started in orchid wont take more than 5 minutes and that is where the blessings of using a framework is in. in next tutorial we will learn how to use a model in orchid. Orchid - http://orchid.phpxperts.net […]
masud
April 6th, 2008 at 8:04 pm
4Thanks a lot.
I am using the http://beta.gopsop.com which is build under the orchid framework.
I just gone through the checkout version of Orchid framework and soon going to play with it.
looking of for more updates.
Make Your Own Web Site » Make Your Own Web Site
April 7th, 2008 at 5:22 pm
5Make Your Own Web Site » Make Your Own Web Site…
As a final bid for bringing together community through the library a calendaring system could be implemented which gives all recognized community organizations an opportunity to plug into a central calendar system, hosted by the library; providing a li…
loan homes
April 8th, 2008 at 3:41 pm
6loan homes…
When you fully embrace this, you will be able to work more comfortably….
nate
April 10th, 2008 at 8:14 pm
7*Sigh*
I really don’t see the point of yet another cheap knock-off MVC framework…
crazyman7
April 11th, 2008 at 7:21 am
8I think that you really can judge people by the way they comment different stuff. Some people, even expressing negative thoughts, are still polite and they respect and understand other people. Some people are not even trying to be nice, they just don’t care. I think self-confident person will always act nice, no matter what other people do
Loan Application
April 26th, 2008 at 4:39 am
9I couldn?t understand some parts of this article rchid, but I guess I just need to check some more resources regarding this, because it sounds interesting.
Php Tutorials
April 30th, 2008 at 11:48 pm
10Good site I “Stumbledupon” it today and gave it a stumble for you.. looking forward to seeing what else you have..later
Rampa
May 2nd, 2008 at 10:27 am
11part is a good topical subject right now
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Links
Meta
Calendar
Orchid is proudly powered by WordPress - BloggingPro theme by: Design Disease