Instalasi GROCERY CRUD pada CODEIGNITER

Halo sahabat ICT Indonesia, kali ini saya akan memposting cara instalasi GROCERY CRUD pada CODEIGNITER. Codeigniter merupakan salah satu framework php yang cukup familiar di kalangan web developer. Kemudian apa itu GROCERY CRUD ? Grocery CRUD merupakan salah satu tools atau bisa di bilang plugin untuk meng-auto render CRUD(Create Read Update Delete) pada codeigniter. Tools ini di kembangkan oleh John Skoumbourdis. Oke langsung saja kita mulai.

Pertama download perlengkapannya dulu :
1. CI yang sudah terinstal.
2. Download Grocery CRUD (download) dalam versi ini penulis menggunakan versi terakhir yaitu Grocery Crud 1.4.1
3. Import database ke XAMPP, caranya create database baru (namanya bebas), kemudian import file examples_database.sql
4. Kemudian konfigurasi database pada ci dengan nama database yang baru dibuat tadi.

Setelah siap semua, penginstalan grocery crud cukup mudah, yaitu tinggal mengkopi semua file grocery crud ke project anda di root codigniter dan anda siap menggunakan grocery crud.

Setelah instalasi, struktur file akan seperti ini (struktur ini adalah struktur default codeigniter setelah di copas file grocery crud) :

website_folder/
–––– application/
–––––––– config/
–––––––––––– autoload.php
–––––––––––– …
–––––––––––– doctypes.php
–––––––––––– foreign_chars.php
–––––––––––– grocery_crud.php
–––––––––––– …
–––––––– controllers/
–––––––––––– examples.php
–––––––––––– index.html
–––––––––––– welcome.php
–––––––– libraries/
–––––––––––– grocery_crud.php
–––––––––––– index.html
–––––––– models/
–––––––––––– grocery_crud_model.php
–––––––––––– index.html
–––––––– views/
–––––––––––– example.php
–––––––––––– index.html
–––––––––––– welcome_message.php
–––– assets/
–––––––– grocery_crud/
–––––––––––– css/
–––––––––––– js/
–––––––––––– texteditor/
–––––––––––– themes/
–––––––– uploads/
–––––––– index.html
–––– system/
–––– user_guide/
–––– change_log.txt
–––– example_database.sql
–––– index.php
–––– licence-grocery-crud.txt
–––– license.txt

Important Note for CI 1.7.x: The only difference between codeigniter 2.0.x and codeigniter 1.7.x is that in 1.7.x you just extends Controller and not CI_Controller and at grocery_model you don’t extend CI_Model but Model. Also make sure that the application folder is in the right place for CI 1.7.x

Berikut ini adalah contoh controller :

 
 if ( ! defined('BASEPATH')) exit('No direct script access allowed');

 
class Examples extends CI_Controller {
 
function __construct()
{
parent::__construct();

 
/* Standard Libraries */
$this->load->database();
$this->load->helper('url');

/* ------------------ */
 
$this->load->library('grocery_CRUD');
}
 
function _example_output($output = null)

{
$this->load->view('example.php',$output);
}
 
function offices()

{
$output = $this->grocery_crud->render();
 
$this->_example_output($output);

}
 
.......
}

 The only required libraries are to connect with the database (that we usually have it as auto-load library) and the url helper.

The variable $output is an object that always includes the following properties – output, js_files, css_files. Below you see an example of a print_r of a variable $output

stdClass Object
(
[output] => Your output will appear here....
[js_files] => Array
(
[763b4d272e158bdb8ed5a12a1824c94f494954bd] => http://grocery_crud/public/grocery_crud/themes/datatables/js/jquery-1.6.2.min.js
[0b677f3fc6fb25b4baf39eb144222116c5b60254] => http://grocery_crud/public/grocery_crud/themes/flexigrid/js/cookies.js
[ec3ae62b8d5838972e858fe54447bd4bd8d79f88] => http://grocery_crud/public/grocery_crud/themes/flexigrid/js/flexigrid.js
[2c0ff56d0cbc6f80a5ef9c770d478f0e00c3170d] => http://grocery_crud/public/grocery_crud/themes/flexigrid/js/jquery.form.js
[474495ff1e895eab81fb8afba4db9b06c15b19af] => http://grocery_crud/public/grocery_crud/themes/flexigrid/js/jquery.numeric.js
)

[css_files] => Array
(
[732b03aa54d124f062757b71e5560acdc5632ba6] => http://grocery_crud/public/grocery_crud/themes/flexigrid/css/flexigrid.css
)

)

The view example.php that its a simple Codeigniter view and includes the below code:

 

"en"
>

"utf-8" />
 

foreach($css_files as $file): ?>
"text/css"
rel="stylesheet" href="" />
 
endforeach; ?>
foreach($js_files as $file): ?>
 

endforeach; ?>
 






'height:20px;'>


echo $output; ?>
 


Footer




 

 Demikian sudah cara install Grocery CRUD pada Codeigniter, mudah bukan tinggal mengkopas file grocery crud ke ci, kemudian jika sudah terinstall , lanjutkan ke artikel selanjutnya Tutorial GROCERY CRUD untuk Pemula.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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