Jumat, 05 November 2010

Hello Word di Code Igniter



Untuk Membuat membuat "Hello word" dengan framework Code Igniter kita harus mempunyai file code igniter,dan pastikan kita sudah menginstal php-server seperti xampp.oh yaw dan pastinya anda punya editornya...






1.file Code Igniter bisa di download di sini
2.extract file nya.dan paste kan di folder htdocs.
3.buka php editor kalian,bisa menggunakan NetBeans IDE,notepad++ ataupun CIgniter.
4.di sini saya akan menggunakan Net Beans,buat file baru File->Open Project->Php->PHP Application With Existing Source.kemudian broswe dan pilih folder yang di extract tadi.
5.buka file config.php di folder App/Config,ubah:
 $config['base_url'] = "http://example.com/";

menjadi
 $config['base_url'] = "http://localhost/test/";

6.buka file routes.php di folder App/Config,ubah:
 $route['default_controller'] = "welcome";

menjadi
 $route['default_controller'] = "c_test";

7.sekarang buat m_test.php di direktori system->application->models
 ?php
Class M_test extends Model {
function M_test(){
parent::Model();
}
function mhello() {
$teks = "Hello word";
return $teks;
}
}
?>


8.buat c_test sebagai controller di direktori system->application->controllers
 ?php
Class C_test extends Controller {
function C_test(){
parent::Controller();
}
function index(){
$this->load->model('M_test','',TRUE);
$data['teks'] = $this->M_test>mhello();
$this->load->view('V_test',$data);
}
}
?>

9.yang terakhir buat v_test sebagai view nya,buat di direktori system->application->views
 <Html><Head> 
<Title>Hello Word</Title>
</Head>
<Body>
<?php
Echo $teks;
?>
</Body></Html>

Dan sekarang tinggal cek di browser anda dengan url "http://localhost/test/"
alhamdulillah selesei tutorial pertama ini gan,,hehehehhe :)

3 komentar:

  1. kok ga bisa ya gan?
    pas load V_test, M_test & C_test itu huruf pertama harus kapital ato boleh kapital boleh kecil?

    BalasHapus
  2. insaalloh boleh gan,,
    tapi mengikuti aturan penulisan kyak a musti gitu,

    maap,wes lama gak ngoding lagi,, hehehe




    Thank's to comment

    BalasHapus

pembaca yang baik selalu menginggalkan jejak