Utilize third-party APIs (Twitter oAuth and Facebook Connect) and make use of some less-known helper functions – CodeIgniter's hidden gems

A step-by-step, practical guide with examples and screenshots

Who This Book Is For

This book is written for advanced PHP developers with a good working knowledge of Object Oriented Programming techniques who are comfortable with developing applications and wish to use CodeIgniter to make their development easier, quicker, and more fun. Basic knowledge of CodeIgniter will be helpful. This book will suit developers who fall into three categories:

Professional Developers – employees of a software house or organization with in-house software development

Freelance Developers – solo developers working in the industry on their own

Just-for-fun Developers – people working with PHP building web applications is their spare time for fun

Table of Contents

Chapter 1: Getting Started with CodeIgniter

Upgrading from older versions of CodeIgniter

Downloading and installing CodeIgniter

Introducing Model View Controller (MVC)

Controllers: The business logic

Models: Data abstraction layer

Views: Your template files

Autoloading resources

Formatting your code—PHP Style Guide

CodeIgniter URLs

CodeIgniter specific files

Summary

Chapter 2: Learning the Libraries

What is a library?

What do libraries do?

Benchmarking Class

Input and Security Class

Email Class

File Uploading Class

Image Manipulation Library

Pagination Class

Session Class

Unit testing a class

Summary

Chapter 3: Form Validation and Database Interaction

Why should I validate my forms?

Using the Form Validation Library

Saving sets of validation rules to a config file

Using callbacks

Database interaction

Performing simple queries

Returning values

Result helper functions

Active Record

Active Record caching

Method chaining

Manipulating databases with Database Forge

Summary

Chapter 4: User Authentication 1

Defining our goals

Creating and connecting to the database

Front end code

Model code

Addressing some issues

The Authentication Library

Summary

Chapter 5: User Authentication 2

Using Twitter oAuth

Using Facebook Connect

Summary

Chapter 6: Application Security

CodeIgniter's defenses

Strong password policies

Storing passwords securely

Database security

Cross-site scripting (XSS)

Changing the default file structure

Staying up-to-date

Summary

Chapter 7: Building a Large-Scale Application

Running benchmarks

Caching

Optimize SQL queries

Avoid disk activity

Run multiple application instances

Summary

Chapter 8: Web Services

What is a web service?

Types of web service

RESTful web service

Create a new post

Update a post

Delete a post

Get a blog post

Summary

Chapter 9: Extending CodeIgniter

Hooks

Extended controllers

Extended libraries

Custom libraries

Helpers

CodeIgniter's hidden gems

Summary

Chapter 10: Developing and Releasing Code to the Community

Find a need in the community (or fill your own need)

Search for existing solutions

Create a plan

Writing the library

Write a user guide

Release options

Handling database tables

Supporting the code

Summary

What You Will Learn

Learn the Model-View-Controller design pattern to structure your code

Create more readable and maintainable queries using the Active Record implementation

Create and maintain database tables using the Database Forge class

Authenticate users using Twitter oAuth and Facebook Connect

Create your own Authentication Library for more control over your user accounts

Secure your application using CodeIgniter's built-in functionality and some quick tips to help further

Learn techniques used by professionals to scale CodeIgniter over multiple servers

Learn top tips for releasing code to the community and giving support to the developers using your code

In Detail

CodeIgniter is an open source PHP framework with a small footprint and exceptional performance. It gives you a rich set of libraries for common tasks, with a simple interface to access them. There are several unexplored aspects of CodeIgniter that can help developers build applications more easily and quickly. In this book, you will learn the intricacies of the framework and explore some of its hidden gems.

If you want to get the most out of CodeIgniter, this book is for you. It teaches you what you need to know to use CodeIgniter on a daily basis. You will create mini-applications that teach a specific technique and let you build on top of the base.

This book will take you through developing applications with CodeIgniter. You will learn how to make your CodeIgniter application more secure than a default installation, how to build large-scale applications and web services, how to release code to the community, and much more. You will be able to authenticate users, validate forms, and also build libraries to complete different tasks and functions.

The book starts off introducing the framework and how to install it on your web server or a local machine. You are introduced to the Model-View-Controller design pattern and how it will affect your development. Some important parts of the CodeIgniter Style Guide are included to keep CodeIgniter development as standardized as possible; this helps greatly when working as part of a team or taking on an old CodeIgniter project. You will quickly move on to how CodeIgniter URLs work and learn about CodeIgniter-specific files such as helpers and plugins. By the time you finish this book, you will be able to create a CodeIgniter application of any size with confidence, ease, and speed.

Authors

Adam Griffiths

Adam Griffiths is a student and freelance CodeIgniter Developer based in the United Kingdom. He has five years web development experience, the last two being largely influenced by CodeIgniter.

Alerts & Offers

Series & Level

We understand your time is important. Uniquely amongst the major publishers, we seek to develop and publish the broadest range of learning and information products on each technology. Every Packt product delivers a specific learning pathway, broadly defined by the Series type. This structured approach enables you to select the pathway which best suits your knowledge level, learning style and task objectives.

Learning

As a new user, these step-by-step tutorial guides will give you all the practical skills necessary to become competent and efficient.

Beginner's Guide

Friendly, informal tutorials that provide a practical introduction using examples, activities, and challenges.

Essentials

Fast paced, concentrated introductions showing the quickest way to put the tool to work in the real world.

Cookbook

A collection of practical self-contained recipes that all users of the technology will find useful for building more powerful and reliable systems.

Blueprints

Guides you through the most common types of project you'll encounter, giving you end-to-end guidance on how to build your specific solution quickly and reliably.

Mastering

Take your skills to the next level with advanced tutorials that will give you confidence to master the tool's most powerful features.

Starting

Accessible to readers adopting the topic, these titles get you into the tool or technology so that you can become an effective user.

Progressing

Building on core skills you already have, these titles share solutions and expertise so you become a highly productive power user.