Chapter 1. Getting Started

This chapter covers the basics of the CI development framework and its usage by reviewing some fundamental web application examples. We will start with a basic hello world example and move to an interactive contact-form integration with a database. We will construct the CI applications by following a step-by-step method. Throughout this chapter, we need to remember that the CI development framework is an MVC-based development architecture (for more information, refer to the Wikipedia definition at http://en.wikipedia.org/wiki/Model-view-controller).

This chapter will primarily focus on the following topics:

  • The CI project directory tree framework
  • Configurations (routing and autoloading are covered in this chapter, while the other issues are covered in Chapter 2, Configurations and Naming Conventions)
  • Example 1: hello world
  • Example 2: passing parameters to a view
  • Example 3: the database query by a model rendering results to a view
  • Example 4: interactive contact forms

By reviewing these examples, we will get the basics of using CI resources. We will begin by briefly reviewing the CI resources used. Then we will review a web application code that loads a static view page. Next we will use the model to retrieve data from a database and show it in a view. Finally, we'll add a view with a contact form to enter input and save it by calling a controller method into the database.

Installing CodeIgniter

First of all, we need to have a hosted PHP server (Version 5.3 or later) and a MySQL (one of the latest versions) server, where we know the database credentials. Local database access from the PHP is recommended for simplicity.

Note that the server will operate in a CGI (Common Gateway Interface) fashion in order to let CI operate. We can have a local web development environment on our PC or a remote server hosted and dedicated.

Once we've set up a local web development environment, we'll need to download the latest version of CI, which is Version 2.1.2 at the time of writing this book. The link to download the latest version is http://codeigniter.com/downloads/. Now, if we look inside the CI folder, we should see the following directory tree:

codeigniter/
  index.php
  application/
  cache/
  config/
  controllers/
  core/
  errors/
  helpers/
  hooks/
  language/
  libraries/
  logs/
  models/
  third_party/
  views/
  system/
  core/
  database/
  fonts/
  helpers/
  language/
  libraries/
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.52.188