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

Comparing CI to other open source solutions (CakePHP and Joomla!)


For one reason or another one should compare these three most of the time and, of course, use one of them. There are other solutions out there, as we have commented before, "few" is not the word to describe PHP frameworks.

Though you would like to have Zend Framework and Symfony in your toolbox, for now, let's use these three for comparison. For example, when Jose heard about frameworks it was all about Ruby on Rails. Before that he used to write his own code for every project. Though Ruby on Rails is a very good framework, for him—a PHP programmer at heart—that was not the solution.

Searching for a PHP framework that was similar to Ruby on Rails, but PHP made, CakePHP was one option. It was quite similar in concept to Ruby on Rails, it also had the same convention-driven architecture that you need to learn before using it. It will pay-back with lots of functionality, automation, and more. But keep in mind that the learning curve is steeper than CodeIgniter's.

Using CakePHP requires you to adhere to some strict conventions (those can be changed but the out-of-the-box software comes with them). Most of the time they are naming conventions, but there are database conventions also.

After some time, because of curiosity, in spite of incredible lack of learning time (some nearby shouting boss also helped), continuing research of PHP frameworks found CodeIgniter. The most convincing thing was the documentation (CakePHP wasn't as well documented as it is today).

CI has less conventions, and minimal configuration, also you can forget about most of them and work as you have always done. You don't want to use models, and you don't have to (though it is recommended). That said, one of the strengths of CI is just that—download it and start programming.

Joomla! is not exactly a framework, it helps you build websites faster. Also in the latest versions it has turned into the MVC (Model-View-Controller) pattern. The good part of Joomla! is that it is a CMS (Content Management System), but I think it is also its bad part, as sometimes you just don't need so much as Joomla! has to offer. Of course you can develop your own solution over Joomla!, but then what's the point of using Joomla!, and not using what it has to offer?

CI, usually, is the most well-balanced of the three, but let's see how we can choose one of them.

What to choose

With all those options out there, why should you go with CI? The answer—it's not that easy and involves, in most cases, personal preference. There will be projects that will be better suited to one of the other two options. Let's see some examples that will guide us.

When to choose Joomla!

  • If we need a CMS (it may sound redundant, but...).

  • If there is already a component, module, or some other functionality that we need, then there is something built that can help us carry out the project in no time.

  • If the client asks you to use it. Joomla! is a well known software, and sometimes your client can just ask you to use it.

When to choose CakePHP

  • If there are lot of relations between database tables. Cake's Active Record capabilities are slightly more powerful than CI's.

  • If you need to build some admin zone quickly. Cake's bake script can read your database and build some CRUD (Create, Read, Update, Delete) pages for your tables.

When to choose CodeIgniter

  • If the project doesn't have or doesn't need a very rigid structure. Also CI is good for working with legacy code.

  • If you need to start programming right away, without having to learn a lot of conventions.

  • If you need some software that helps you, with the confidence that it will help you in the way you really need, and learn the way something needs to be done.

  • If you know PHP, you can use CI.

  • The client needs some solution built specifically for him/her, and not an adapted solution (that would be in case of some Joomla! components/modules).

Most of the time we will be using CI because it is very flexible. If you like programming CI will help you in doing it. It will seem as if CI isn't even there. You realize it only when you look at the time you are gaining and the better structure of your project.

If you are new to frameworks it is recommended that you get CI, maybe later you use another one (probably both of them), but CI will always have a place in your heart.

Note

Packt Publishing has books on some other frameworks and Joomla!. It is recommended to read them, it will give you a broader view of things.

For books on Joomla visit http://www.packtpub.com/joomla-version-1-5/book.

For books on CakePHP visit http://www.packtpub.com/cakephp-application-development/book.