How to make MVC framework

ဒီနေ့တော့ ရေးတာ ပြီးသွားပါပြီ။ အရင်တုန်းက ရေးထားတဲ့ library လေး ကောက်ထည့်ပြီးရင် ကျွန်တော် အရင်ကရေးထားတဲ့ framework က MVC ဖြစ်သွားပြီ။ MVC ရေးရတာ မခက်ပါဘူး။ OOP နားလည်ရင်ရပါပြီ။ ကျွန်တော် သုံးထားတဲ့ File Structure လေး ကြည့်ကြည့်ပါ။

index.php ကနေ init.php ကိုခေါ်တယ်။ အဲဒီကနေ router ကနေ တဆင့် Controller ကို ခေါ်တယ်။ router က ဝင်လာတဲ့ Address ကို controller နဲ့ action ခွဲပေးတယ်။

ဥပမာ။။ example.com/controller/action

ဆိုရင် controller နဲ့ action ကို router က ခွဲထုတ်ပေးတယ်။

Controller ကနေ Model ပြန်ခေါ်ဖို့ Loader သုံးတယ်။ Model ကနေ View ပြန်ခေါ်ဖို့ Loader ပဲပြန်သုံးတာပဲ။ ကဲ… ဒါပဲ။ ရိုးတယ်။ ရှင်းတယ်။ ဘာမှ ခက်ခက်ခဲခဲရေးစရာမလို။ ပြီးရင် လက်ရှိ ရေးထားတဲ့ Library တွေ ကောက်ထည့်လိုက်ရင် ပြီးပြီ။ MVC framework ရေးရတာ ထင်သလောက် မခက်ပါဘူးဗျာ။ ရေးထားတဲ့ source code တော့ လာမတောင်းနဲ့။ မပေးနိုင်ပါ။ opensource မဟုတ်သလို ပေးဖို့လည်း စိတ်ကူးမရှိဘူး။ ဒီလောက် ရေးရတာ လွယ်လွယ်လေးကို။ တကယ်လို့ မသိဘူးဆိုရင်တော့ အောက်က link ၂ ခုကနေ လေ့လာလို့ရပါတယ်။ controller code ကတော့ မနေ့က ရေးပေးဖူးတယ်။

http://www.phpro.org/tutorials/Model-View-Controller-MVC.html

http://net.tutsplus.com/tutorials/php/creating-a-php5-framework-part-1/

http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>