CodeIgniter Practice

1,302 views

Published on

CodeIgniter in practice

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,302
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
62
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

CodeIgniter Practice

  1. 1. CodeIgniter Practice Jamshid Hashimi Trainer, Cresco Solution http://www.jamshidhashimi.com jamshid@netlinks.af @jamshidhashimi ajamshidhashimi Afghanistan Workforce Development Program
  2. 2. Agenda • Create an Application with CodeIgniter • Common Functions • URI Routing • Error Handling • Caching • Profiling CodeIgniter Application
  3. 3. Create an Application with CodeIgniter • Controllers – Functions • Views – Template folder • Helpers – Handling tempaltes • Libraries
  4. 4. DEMO
  5. 5. Common Functions • CodeIgniter uses a few functions for its operation that are globally defined, and are available to you at any point. These do not require loading any libraries or helpers. – is_php('version_number') – is_really_writable('path/to/file') – config_item('item_key') – show_error('message') – show_404('page') – log_message('level', 'message') • error • debug • Info
  6. 6. DEMO
  7. 7. URI Routing • Typically there is a one-to-one relationship between a URL string and its corresponding controller class/method. $route['journals'] = "blogs"; $route['blog/joe'] = "blogs/users/34"; $route['product/(:any)'] = "catalog/product_lookup"; $route['product/(:num)'] = "catalog/product_lookup_by_id/$1”;
  8. 8. DEMO
  9. 9. Error Handling • CodeIgniter lets you build error reporting into your applications using the functions described below. In addition, it has an error logging class that permits error and debugging messages to be saved as text files. – show_error('message' [, int $status_code= 500 ] ) – show_404('page' [, 'log_error']) – log_message('level', 'message') • error • debug • Info
  10. 10. Caching • CodeIgniter lets you cache your pages in order to achieve maximum performance. $this->output->cache(n);
  11. 11. DEMO
  12. 12. Profiling CodeIgniter Application • The Profiler Class will display benchmark results, queries you have run, and $_POST data at the bottom of your pages. This information can be useful during development in order to help with debugging and optimization. $this->output->enable_profiler(TRUE);
  13. 13. Profiling CodeIgniter Application • Each section of Profiler data can be enabled or disabled by setting a corresponding config variable to TRUE or FALSE. • Override in Controller $config['config'] = FALSE; $config['queries'] = FALSE; $sections = array( 'config' => TRUE, 'queries' => TRUE ); $this->output->set_profiler_sections($sections);
  14. 14. DEMO
  15. 15. QUESTIONS?

×