Book Image

CodeIgniter for Rapid PHP Application Development

By : David Upton
Book Image

CodeIgniter for Rapid PHP Application Development

By: David Upton

Overview of this book

<p>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.<br /><br />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.</p>
Table of Contents (21 chapters)
CodeIgniter for Rapid PHP Application Development
Credits
About the Author
About the Reviewers
Preface
Index

Preface

This book sets out to explain some of the main features of CI. It doesn't cover them all, or cover any of them in full detail. CI comes with an excellent on-line User Guide that explains most things. This is downloaded with the CI files.

This book doesn't try to duplicate the User Guide. Instead it tries to make it easier for you to pick up how the CI framework works, so you can decide whether it is right for you, and start using it quickly.

In some places, this book goes beyond the User Guide, though, when it tries to explain how CI works. (The User Guide is more practically oriented.) This means that there are some fairly theoretical chapters in between the "here's how" pages. I've found that it helps to understand what CI is doing under the hood; otherwise you sometimes get puzzling error messages that aren't easy to resolve.

I've tried to use a 'real-world' example when showing sections of CI code. I want to show that CI can be used to develop a serious website with a serious purpose. I'm currently running several websites for clients, and I want a program that will monitor them, test them in ways I specify, keep a database of what it has done, and let me have reports when I want them.

The examples in this book don't show it in full detail, of course: but they do, I hope, demonstrate that you can use CI to make pretty well any common coding simpler, and some uncommon stuff as well.

This book steps you through the main features of CodeIgniter in a systematic way, explaining them clearly with illustrative code examples.

What This Book Covers

Chapter 1 explains what CodeIgniter can do, the 'framework', and how CodeIgniter fits in. It further talks about the open-source business model and gives some disadvantages of CodeIgniter, at the end.

Chapter 2 explains what happens when you install the site, and which files will be created. It gives a detailed overview of the required software, and explains the basic configuration of CodeIgniter.

Chapter 3 explains how MVC helps to organize a dynamic website. It goes further to explain the process by which CodeIgniter analyzes an incoming Internet request and decodes which part of your code will handle it. Then CodeIgniter syntax rules and the different types of files or classes you can find—or write for yourself—on a CodeIgniter site are explained. At the end of the chapter, some practical hints on site design are given.

Chapter 4 looks at how you set up a database to work with CodeIgniter, and then how you use the Active Record class to manipulate the database.

Chapter 5 covers various ways of building views, how to create HTML forms quickly, and how to validate your forms using CodeIgniter's validation class.

Chapter 6 looks at one of the basic questions affecting any website i.e. session management and security; we also explore CodeIgniter's session class.

Chapter 7 covers the way in which CodeIgniter uses objects, and the different ways in which you can write and use your own objects.

Chapter 8 covers CodeIgniter classes to help with testing: Unit tests, Benchmarking, the 'profiler' and ways in which CodeIgniter helps you to involve your database in tests without scrambling live data.

Chapter 9 looks at using CodeIgniter's FTP class and email class to make communication easier, and then we venture into Web 2.0 territory using XML-RPC.

Chapter 10 talks about CodeIgniter classes that help in overcoming problems arising regularly when you are building a website, for example, the date helper, the text and inflector helpers, the language class, and the table class.

Chapter 11 looks at several useful CodeIgniter functions and helpers: file helper, download helper, file upload class, image manipulation class, and the ZIP class.

Chapter 12 covers exploring your config files, using diagnostic tools, and potential differences between servers, along with some notes on security.

Chapter 13 shows you how to generalize CRUD operations so that you can do them with two classes: one for the controller, and one for the CRUD model.

Chapter 14 looks at some coding examples, bringing together a lot of the functions that have been discussed bit by bit in the preceding chapters.

Chapter 15 looks at some of the resources available to you when you start to code with CodeIgniter, such as the libraries for AJAX and JavaScript, authentication, charting, and CRUD.

What You Need for This Book

Throughout this book, we will assume that you have the following packages installed and available:

  • PHP 4.3.2 or above

  • A working web server

  • One of MySQL, MySQLi, MS SQL, Postgre, Oracle, SQLite, ODBC

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.

There are three styles for code. Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code will be set as follows:

$active_group = "default";
$db['default']['hostname'] = "";
$db['default']['username'] = "";
$db['default']['password'] = "";

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

</head>
<body>
<h1 class='test'><?php echo $mytitle; ?> </h1>
<p class='test'><?php echo $mytext; ?> </p>
</body>

New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "clicking the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box 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 , making sure to 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/support, and select this book from the list of titles to download any example code or extra resources for this book. The files available for download will then be displayed.

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 this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the Submit Errata link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Questions

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