Getting Started with CodeIgniter

Auto load the following libraries and helpers by putting the following code lines in application/config/autoload.php:

$autoload['libraries'] = array('database');
$autoload['helper'] = array('url', 'file');

Creating a new model as application/models/post_model.php:

db->select('post_title, post_content, post_date'); 
        $query = $this->db->get('wizey_posts');
        if ($query->num_rows() > 0)
          return $query->result();
        } else {
          return array();

Creating a new controller as application/controllers/blog.php:

load->model('Blog_model', 'blog');
      $data['query'] = $this->blog->getall();
      $this->load->view('index', $data);


Creating a new View as applications/views/index.php:


post_title; ?>

post_content; ?> post_date; ?>

Create a new table named “wizey_posts” in connected database using PHPMYADMIN and create new fields in it naming “post_id”, “post_title”, “post_content” and “post_date”. Insert sample data there using the same interface. Make sure to set the correct value to $route[‘default_controller’] in application/config/routes.php

To be able to enable Profiling of code, make sure the following code lines are present in php configuration file php.ini,

; XDEBUG Extension
zend_extension = "c:/wamp/bin/php/php5.4.3/zend_ext/php_xdebug-2.2.0-5.4-vc9-x86_64.dll"
xdebug.remote_enable = On
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = Off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_port = 9000

Restart Apache and verify that xdebug is enabled by using the phpinfo(); function. Then Download Webgrind from github and edit it’s configuration file and change the $storageDir and $profilerDir variables to match the same directory you mentioned in php.ini’s xdebug.profiler_output_dir variable. Also put “php_flag xdebug.profiler_enable 0” without quotes in .htacess file in webgrind directory to prevent it’s own profiling.

Leave a comment

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