Book Image

CodeIgniter 1.7 Professional Development

By : Adam Griffiths
Book Image

CodeIgniter 1.7 Professional Development

By: Adam Griffiths

Overview of this book

<p>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.<br /><br />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. <br /><br />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.<br /><br />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.</p>
Table of Contents (16 chapters)
CodeIgniter 1.7 Professional Development
Credits
About the Author
About the Reviewers
Preface
Index

CodeIgniter URLs


CodeIgniter URLs use Uniform Resource Identifiers (URI). In simple terms, CodeIgniter's URLs are simply segments. These segments are then split up and used to load a particular controller and method. Here is a typical CodeIgniter URL:

Everything after the index.php segment is used by CodeIgniter to determine what to load. The first segment is the name of the Controller. The second segment is used to determine which function to load—if this is blank then the index function will be used. The final segment will be used to pass any data to the function.

Removing the index.php file

You can remove the index.php part of the URL by adding a .htaccess file to the root of your CodeIgniter install. Here is an example file:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

This will redirect anything to the index.php file except for index.php, the images folder, and robots.txt. You can add any other items to the list as you so wish, such as a folder for .css files or even JavaScript files.

Adding a URL Suffix

You can specify in your system/application/config/config.php file to add a suffix to your URLs. Take this example:

http://mywebxite.ext/products/books/

You can add a suffix so that the URL becomes:

http://mywebsite.ext/products/books.html

You don't have to use .html, I just used it as an example.