Codeigniter 3 Installation

This is a full tutorial of a suggested way to install Grocery CRUD Enterprise to your already existing project with Codeigniter framework.

First of all, the most common usage of Grocery CRUD Enteprise is an upgrade from the community edition. That simply means the project is built with Codeigniter framework and it is very possible to already have installed Grocery CRUD Community edition. So at the below steps we are trying to have an installation guide without causing any conflicts to the already existing community version (so you can use both if you like).

Step 1. From the email that you’ve received or from the user’s page (you will get instructions at the email of how to access user’s page) download the file that say’s “Without composer”. Once you’ve downloaded it, unzip it!
The folder structure that you will get is the following:

├── examples
│   ├── config.php
│   ├── database.php
│   ├── example.php
│   └── view.php
├── libraries
│   ├── autoload.php
│   ├── bin
│   ├── composer
│   ├── ...
│   ├── phpunit
│   ├── symfony
│   └── zendframework
└── public
    └── grocery-crud
        ├── css
        ├── fonts
        ├── images
        └── js

Step 2. rename the folder libraries to GroceryCrudEnterprise and move it to your project at the following path application/libraries/GroceryCrudEnterprise with this structure we simply follow the “Codeigniter way” of adding libraries.
Step 3. go to the folder public and copy the folder grocery-crud to your assets folder of your Codeigniter project. If you don’t have one, then it will be good to create one!

Step4. We did currently installed Grocery CRUD Enterprise in our project and we need to create our configuration files in order to make it work. Rename the configuration files from examples: config.php to gcrud-enterprise.php and copy it to application/config folder at your project. Don’t forget to add at your config file the path for the folder at the file gcrud-enterprise.php . In your case it will be:

'assets_folder' => base_url() . 'assets/grocery-crud/',
So far your Codeigniter project should look like this:
├── application
│   ├── cache
│   ├── config
│   │   ├── autoload.php
│   │   ├── ...
│   │   ├── gcrud-enterprise.php
│   │   ├── ...
│   │   └── user_agents.php
│   ├── controllers
│   ├── core
│   ├── errors
│   ├── helpers
│   ├── hooks
│   ├── language
│   ├── libraries
│   │   ├── GroceryCrudEnterprise
│   │   │   ├── autoload.php
│   │   │   ├── bin
│   │   │   ├── composer
│   │   │   ├── ...
│   │   │   ├── phpunit
│   │   │   ├── symfony
│   │   │   └── zendframework
│   │   ├── ...
│   │   ├── ...
│   │   └── index.html
│   ├── logs
│   ├── models
│   ├── private
│   ├── third_party
│   └── views
├── assets
│   ├── ...
│   ├── grocery-crud
│   │   ├── css
│   │   ├── fonts
│   │   ├── images
│   │   └── js
│   └── ...
└── system

and your file application/config/gcrud-enteprise.php will look something like this:

return [
    // So far 34 languages including: Afrikaans, Arabic, Bengali, Bulgarian, Catalan, Chinese, Czech, Danish,
    // Dutch, English, French, German, Greek, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean,
    // Lithuanian, Mongolian, Norwegian, Persian, Polish, Portuguese, Brazilian Portuguese, Romanian,
    // Russian, Slovak, Spanish, Thai, Turkish, Ukrainian, Vietnamese
    'default_language'	=> 'English',

    // This is the assets folder where all the JavaScript, CSS, images and font files are located
    'assets_folder' => base_url() . 'assets/grocery-crud/',

    // There are only three choices: "uk-date" (dd/mm/yyyy), "us-date" (mm/dd/yyyy) or "sql-date" (yyyy-mm-dd)
    'date_format' => 'uk-date',

    // The default per page when a user firstly see a list page
    'default_per_page'	=> 10,

    // Having some options at the list paging. This is the default one that all the websites are using.
    // Make sure that the number of grocery_crud_default_per_page variable is included to this array.
    'paging_options' => ['10', '25', '50', '100'],

    // The environment is important so we can have specific configurations for specific environments
    'environment' => 'development',

    // The default skin that Grocery CRUD will use. Currently choose between 'bootstrap-v3' and 'bootstrap-v4'
    'skin' => 'bootstrap-v3',

    // This is basically in order to have some basic cache for the initial calls mainly for field types
    // of a database table
    'backend_cache' => false,

    'xss_clean' => false,

    // The character limiter at the datagrid columns, zero(0) value if you don't want any character
    // limitation to the column
    'column_character_limiter' => 50,

    // You can choose between 'minimal' or 'full'
    'text_editor_type' => 'full',

    // If open_in_modal is true then all the form operations (e.g. add, edit, clone... e.t.c.) will
    // open within a modal and we will have the datagrid on the background.
    // In case you would like however to have a standalone page for all the form operations change this to false.
    'open_in_modal' => true,

    // This is the hash symbol (#) that we have at the URL in order to have tha basic operations in the URL so you
    // can navigate back to the URL that you were. For example, when you click at edit form for the id 46, the
    // URL will also change to #/edit/46 so you can also share the link.
    // In case you would like to switch this functionality to off change this to false.
    'hash_in_url' => true,

    // The maximum number of buttons that we would like to have for the actions buttons.
    // If the number of buttons exceeds this number then the last button on the right
    // is going to change into a "More" dropdown button.
    // If the maximum number is 1 then as we only have one button as a dropdown list the translation
    // is "Actions" rather than "More"
    'max_action_buttons' => [
        'mobile' => 1,
        'desktop' => 2

    // For more read
    // If you are not sure about how to use it, you can just change the ttl value (time to live) and
    // the file path of the cache
    'cache' => [
        'adapter' => [
            'name'    => 'filesystem',
            'options' => [
                'namespace' => 'gcrud',
                'ttl' => 3600 * 24 * 30 * 6,
                'cache_dir' => realpath(__DIR__ . '/Cache/')
        'plugins' => [
            'exception_handler' => ['throw_exceptions' => false],

Important Notice: The most common mistake of the installation of grocery CRUD Enteprise is when the assets_folder has a wrong path. If you did follow all the steps and you see that your webpage looks like that:


then make sure that you have configured your application/config/config.php file at $config[‘base_url’]. For example if your project URL looks like this:
http://localhost/my-test-project/index.php then your base_url should look like this:
$config['base_url'] = 'http://localhost/my-test-project/';

Step5. Now you are ready basically to use grocery CRUD Enterprise. You only need some small modifications. The easiest way to create two private methods to your controller that it will look like this:

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

// Add those two lines at the beginning of your controller
include(APPPATH . 'libraries/GroceryCrudEnterprise/autoload.php');
use GroceryCrud\Core\GroceryCrud;


private function _getDbData() {
        $db = [];
        include(APPPATH . 'config/database.php');
        return [
            'adapter' => [
                'driver' => 'Pdo_Mysql',
                'host'     => $db['default']['hostname'],
                'database' => $db['default']['database'],
                'username' => $db['default']['username'],
                'password' => $db['default']['password'],
                'charset' => 'utf8'
private function _getGroceryCrudEnterprise($bootstrap = true, $jquery = true) {
        $db = $this->_getDbData();
        $config = include(APPPATH . 'config/gcrud-enterprise.php');
        $groceryCrud = new GroceryCrud($config, $db);
        return $groceryCrud;

And now when you want to use groceryCRUD enterprise you will simply do this:

// Your function at your controller
public function demo_set_model()
    $crud = $this->_getGroceryCrudEnterprise();
    $crud->setSubject('Customer', 'Customers');
    $output = $crud->render();

function _example_output($output = null) {
    if (isset($output->isJSONResponse) && $output->isJSONResponse) {
                header('Content-Type: application/json; charset=utf-8');
                echo $output->output;


The example.php is located at: application/views/example.php and it is the exact same view that we were using as an example at Community edition. More specifically the view example.php contains the below code:

<!DOCTYPE html>
<html lang="en">
 <meta charset="utf-8" />
foreach($css_files as $file): ?>
 <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
 <script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
<style type='text/css'>
 font-family: Arial;
 font-size: 14px;
a {
 color: blue;
 text-decoration: none;
 font-size: 14px;
 text-decoration: underline;
<!-- Beginning header -->
 <a href='<?php echo site_url('examples/offices_management')?>'>Offices</a> | 
 <a href='<?php echo site_url('examples/employees_management')?>'>Employees</a> |
 <a href='<?php echo site_url('examples/customers_management')?>'>Customers</a> |
 <a href='<?php echo site_url('examples/orders_management')?>'>Orders</a> |
 <a href='<?php echo site_url('examples/products_management')?>'>Products</a> | 
 <a href='<?php echo site_url('examples/film_management')?>'>Films</a>
<!-- End of header-->
 <div style='height:20px;'></div> 
<?php echo $output; ?>
<!-- Beginning footer -->
<!-- End of Footer -->

Notice: Grocery CRUD Enterprise is a framework agnostic library. That simply means that it doesn’t matter which framework you are using and it doesn’t matter the architecture you are using. This tutorial is taking some architecture decisions basically for you. If you need to have the full freedom of what structure to choose we are suggesting to see the full installation guide here.

Update: If you would like to see a quick video tutorial of how to install Grocery CRUD Enterprise with Codeigniter from scratch you can go straight away and see the video here: Grocery CRUD Enterprise – Installation for Codeigniter

Latest Update: As I had many requests to basically have a full example with Codeigniter into one place, you can find everything that I’ve just describe above with the latest Codeigniter version and with the latest Grocery CRUD Enterprise at this link: by downloading with Codeigniter X.X.X. Although it is not required, it is fully suggested to read this document first as it useful for you to understand better the file structure.