Book Image

CodeIgniter 1.7

Book Image

CodeIgniter 1.7

Overview of this book

CodeIgniter (CI) is a powerful open-source PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. CodeIgniter is an MVC framework, similar in some ways to the Rails framework for Ruby, and is designed to enable, not overwhelm. This book explains how to work with CodeIgniter in a clear logical way. It is not a detailed guide to the syntax of CodeIgniter, but makes an ideal complement to the existing online CodeIgniter user guide, helping you grasp the bigger picture and bringing together many ideas to get your application development started as smoothly as possible. This book will start you from the basics, installing CodeIgniter, understanding its structure and the MVC pattern. You will also learn how to use some of the most important CodeIgniter libraries and helpers, upload it to a shared server, and take care of the most common problems. If you are new to CodeIgniter, this book will guide you from bottom to top. If you are an experienced developer or already know about CodeIgniter, here you will find ideas and code examples to compare to your own.
Table of Contents (21 chapters)
CodeIgniter 1.7
Credits
About the Authors
About the Reviewer
Preface

Preface

CodeIgniter (CI) is a powerful open source PHP framework with a very small footprint, built for PHP programmers who need a simple and elegant toolkit to create full-featured web applications. CodeIgniter is an MVC framework, similar in some ways to the Rails framework for Ruby, and is designed to enable, not overwhelm. This book explains how to work with CodeIgniter in a clear logical way.

What this book covers

Chapter 1: Introduction to CodeIgniter, will introduce you to what frameworks are, and specifically we will talk about CI and how it can help in our day to day work. We will see what CI offers and what it doesn't.

Chapter 2: Setting up a CodeIgniter Site, will help you to prepare the basic configuration of your site, studying CI's structure and config files. At the end you will have a working CI installation.

Chapter 3: Navigating Your Site, will cover some important topics, like the MVC pattern and how CI handles this pattern, and we will make an example controller just to see how all this works.

Chapter 4: Using CI to Simplify Databases, helps you to start working with databases. This is a very important topic. CI will really help us at this point, so we are going to see in detail all the tools at our disposal, including Active Record.

Chapter 5: Simplifying HTML Pages and Forms, will help you with HTML and form helpers, which are some important tools you will find in CodeIgniter; we will see some examples about their usage and introduce form validation.

Chapter 6: Simplifying Sessions and Security, will cover some important security features of CI, which will help make your site more secure. As we will also talk about sessions we will build a simple login feature.

Chapter 7: CodeIgniter and Objects, introduces a bit on object-oriented programming and how CI makes use of it, including the use of the CI super object, and how we can modify and use it.

Chapter 8: Improving Our Application with Third-Party Code, will help you take some rest from the hard work you have done in the previous chapters. We will see some third-party code that we can easily add to our site, improving it, and adding interesting functionalities.

Chapter 9: Using CI to Communicate, explains how CI helps us in communication. Communication is an important part of every site. We will see the ftp class, email class, and XML-RPC class and, of course, the possibility to add more as we need!

Chapter 10: How CI Helps to Provide Dynamic Information, will show some more useful helpers and classes, this will include the date helper, text helper, and table and language classes. All of this will help in the development of our site, not only in reducing code, but in adding powerful features to our working toolbox.

Chapter 11: Using CI to Handle Files and Images, will be about files, uploading, downloading, and compressing them, of course, all with CI classes! As always those classes will make our life easier. Image treatment also has some space in the chapter as CI has some nice features to crop, reduce, watermark, and so on.

Chapter 12: Moving Your Site to the WWW, will finally show you how to upload your site to a shared host or similar. Here we will see in detail how to do that, and also what kind of error we can expect to encounter.

Chapter 13: CRUD—or Putting It All Together, will be a chapter of "putting it all together", where we'll take time to recap and emphasize the most important topics covered to the moment. Insert, edit, and remove records from the database are some topics we will see here, but also ordering and pagination of results.

Chapter 14: The Verdict on CI, will summarize the key points of CI, not to forget anything, as every little thing CI offers will be of great help.

Chapter 15: Resources and Extensions, will give a list of resources and third-party code—we don't want to reinvent the wheel! We will take a look at some useful extensions such as authentication, PDF generation, invoicing, and much more.

The Appendix will introduce a new and interesting CI feature, the cart class; building a store has never been easier!

What you need for this book

Only basic PHP and HTML knowledge is needed to understand this book. All the rest is explained here from top to bottom. You won't get lost!

Who this book is for

This book is not only for PHP developers who want to be more productive at work, but also for those who are new to web programming and are searching for a useful tool that helps in their work. If you are tired of writing the same code again and again, this book is for you. If you want to create more robust and easier-to-maintain PHP sites, again this book is for you. But this book is really for you if you want to enjoy PHP programming with a framework that really helps you.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Our password variable contains a password that looks quite secure, but will produce a problem in our query."

A block of code will be set as follows:

$this->load->database('websites');
$query = $this->db->get('sites');
foreach ($query->result() as $row)
{
print $row->url;
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be shown in bold:

<head>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'http:\/\/www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http:\/\/www.w3.org/1999/xhtml'>
<title>Web test Site</title>
<link rel="stylesheet" type="text/css" href="<?php echo $base."/".$css;?>">
</head>

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "When you click on the Buy button, you will be returned to this page again".

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an email to , and mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code for the book

Visit http://www.packtpub.com/files/code/9485_Code.zip to directly download the example code.

Note

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.