Book Image

CodeIgniter Web Application Blueprints

Book Image

CodeIgniter Web Application Blueprints

Overview of this book

Table of Contents (16 chapters)
CodeIgniter Web Application Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

This book comprises eight projects. These projects are deliberately made with extension and modification in mind, that is, as much as possible, I've tried to build each project in such a way that you can apply your own requirements easily and you don't have to study the code for weeks on end to work out how it functions.

Following each chapter as they currently are will give you a perfectly functioning project, of course, but there is always room to expand and should you choose to extend and add functionality, you can do so easily.

Conversely, each project can be disassembled and specific sections of code can be lifted out and used in completely different projects that are totally separate to this book. I've done this in several ways—as much as possible, the code is kept verbose and simple. The code is kept in small, manageable blocks; I've tried to keep all code as close to the examples of code used in the CodeIgniter documentation (so hopefully, it will follow a familiar flow and appearance).

I've also tried to document each project. The beginning of each chapter will contain wireframes, sitemaps, file tree layouts, and data dictionaries of every table in each project, and in the code itself, I have added explanations of the code.

I try to discuss why something is there rather than just a stale explanation of what something is; this is done in the hope that explaining why something is there will help you understand how relevant the code is to whatever change or amendment you might have in mind.

What this book covers

Chapter 1, Introduction and Shared Project Resources, introduces you to this book and documents an initial development environment—installing Twitter Bootstrap, installing CodeIgniter, and developing a few shared common resources used by all chapters throughout the book.

Chapter 2, A URL Shortener, talks about creating an application that allows a user to enter a URL. The application will encode this URL and generate a new, shorter URL with a unique code appended to it—this will then be saved to a database. This URL will be offered to the user for them to distribute and use. Once it is clicked on, the application we will develop will look at the URL, find the unique code in that URL, and look for it in the database. If found, the application will load the original URL and redirect the user to it.

Chapter 3, Discussion Forum, talks about creating an application that will allow users to create an initial question or proposition. This question will be displayed on a type of notice board; this is the beginning of a discussion thread. Other users are able to click on these users' discussions and reply to them should they wish.

Chapter 4, Creating a Photo-sharing Application, talks about creating a small application that will allow a user to upload an image. A unique URL is then generated and saved to the database along with details of the uploaded file. It is offered to the user for them to distribute. Once the URL is clicked on, the uploaded image is fetched from the filesystem and displayed to the user.

Chapter 5, Creating a Newsletter Signup, contains a project that allows a user to register to a database of contacts, in this case, a database of newsletter signups. The user can amend their settings (the settings can be anything you wish: the type of e-mail content they wish to receive or whether they wish to receive HTML or text-only e-mails). The application even supports unsubscribing from future newsletters.

Chapter 6, Creating an Authentication System, contains an application to manage users in a system you might develop and is perhaps the largest chapter in the book. A simple CRUD environment is supplied, allowing you to add, edit, and delete users. In turn, users can register themselves and even reset their password should they forget it.

Chapter 7, Creating an E-Commerce Site, talks about a small but concise e-commerce application that utilizes CodeIgniter's Cart class to support a simple shop. Users can filter products via different categories, add products to their cart, amend items in the carts (adjust item quantities), or remove items from their cart altogether.

Chapter 8, Creating a To-do List, talks about creating an application that allows a user to create tasks that they need to complete. Tasks can be given a due date, that is, a kind of deadline date. The tasks are displayed in an HTML table. The rows of late tasks are given a red background color to indicate their importance. Complete tasks can be set as done and are indicated as being done by being struck through. Finally, tasks can be deleted to remove old and unwanted items.

Chapter 9, Creating a Job Board, talks about creating a job board. Users are encouraged to post an advert on the job board by filling in an HTML form. The contents of the form are validated and added to a database of current available jobs. Other users looking for work can search for these jobs. These users can search through all jobs or enter a search query to see whether a specific job exists.

What you need for this book

The following is what you need:

  • You'll need a computer and an *AMP environment (MAMP, WAMP, LAMP, and so on)

  • A copy of the CodeIgniter framework

Who this book is for

In short, this book is anyone; you don't have to have previous CodeIgniter experience—however, this will obviously help. That said, this book isn't really aimed at the beginner, but that is by no means a barrier; don't forget, CodeIgniter is an easy-to-use framework and can be picked up quite easily.

Conventions

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

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Create or open a .htaccess file."

A block of code is set as follows:

$this->load->model('Urls_model');
if ($res = $this->Urls_model->save_url($data)) {
  $page_data['success_fail'] = 'success'; 
  $page_data['encoded_url'] = $res; 
} else {
  $page_data['success_fail'] = 'fail'; 
}

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

if ($this->form_validation->run() == FALSE) {
     // Set initial values for the view
$page_data = array('success_fail'   => null,
                   'encoded_url'    => false);

Any command-line input or output is written as follows:

user@server:/path/to/codeigniter$ php tools/spark install -v1.0.0 example-spark

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Enter the following command and click on OK."

Note

Warnings or important notes appear in a box like this.

Tip

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 disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

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 at 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

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

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

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.