Book Image

Programming with CodeIgniter MVC

Book Image

Programming with CodeIgniter MVC

Overview of this book

The CodeIgniter Model-View-Controller framework provides genius simplicity, flexibility, and efficient resource usage, boosting performance and reusability. "Programming with CodeIgniter MVC" reviews the unique features of CodeIgniter using simple, easy-to-follow, and practical examples. Programming with CodeIgniter MVC provides a simple step-by-step guide to efficiently utilizingthe CodeIgniter MVC framework for developing web applications. This book is packed with engaging examples to understand the usage of controllers, libraries, and (Codeigniter) CI Models. This book commences with a quick discussion of the CodeIgniter Integration with  external plugins such as Flickr API, Google Maps and more will be reviewed with clear usage examples. It will then cover CI naming convention rules, mandatory and optional configurations, and usage within a CI project. It will also cover user defined configurations. By the end of this book, you will not only understand user-defined libraries in a CI framework, but also their services, role, usage, and scope with the help of an example-based approach. The book also covers helpers, models, and views, as well as their usage. Using this book, youwill soonbe able to develop feature-rich web applications using the CodeIgniter MVC framework. "Programming with CodeIgniter MVC" is a one-stop solution to developing solutions with CodeIgniter MVC.
Table of Contents (15 chapters)
Programming with CodeIgniter MVC
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Appendix
Index

Example 1 – default homepage controller


Initially, we will start with a simple controller example that opens a home page with the navigation option back and forth to another page B, and similarly to the home page. We will do so while rendering some controller calculated data at the view.

This example doesn't use the database. This example will be built from the following CI framework component configuration, controller, and view files.

Let us define the default controller filename as controller/home_page.php and the home page view as views/home_page_view.php.

Let us assume the URI to the project root is http://mydomain.com/myproject.

The controller file

The controller file /home_page.php will prepare some data to be shown in the view and will let the user navigate to page B and similarly back to the home page.

The helpers used are provided with the sample source code provided with this book.

The following is the code:

<?php
class Home_page extends CI_Controller
{
  function __construct() {
 ...