What is a framework? Why use it instead of plain PHP? Ever since it's release, CodeIgniter has been popular with developers worldwide. While it is not as robust as other frameworks, it does present a well-made, well-maintained set of tools to get the job done. Let's check out some of the advantages of using a framework compared to just using just PHP (code-wise and time-wise), and how to workaround certain limitations (either PHP-wise or CodeIgniter-wise).
- [Instructor] What is Codelgniter? Is it a program? Is it a programming language? Is it better than PHP? Let's answer these questions so we can have a better idea of what Codelgniter is and how it can speed up planning and development. Codelgniter is not a programming language nor a program by itself. Codelgniter is a framework made in PHP. That is, PHP is a programming language and Codelgniter is an extended set of functions, helpers and libraries that make up the framework. But then, what is a framework? A framework is in fact, an enhanced toolset which may be integrated into any programming language.
That is to say, that over the years, developers have solved the same problems over and over again. So a group of developers packed these solutions into a framework. This framework can be extended and is ready to be used in our applications. It's like a Swiss army knife ready to be used when needed. It may also serve as an initial boiler plate. Why should we use Codelgniter over plain PHP? Well, for several reasons. For one, Codelgniter solves common problems. Since they're already solved, we don't have to write the code to solve these issues but rather, implement what's already solved.
This saves us from a lot of coding and translates into much less code. Two, because of Codelgniter's maturity, the solutions that it offers have been tested over the years. So we don't have to worry about them not working properly. Three, the solutions provided by Codelgniter have been tested for functionality so that we don't have to waste time in thinking how to solve that of basic implementation or session handling to name a few. In other words, we don't have to reinvent things. They've already been thought out for us.
Four, Codelgniter gives us the tools that if properly used, can help us keep our application clean and separated into three components, known as the MVC or the Model View Controller Architecture Pattern. We will go over in depth in an upcoming video. And lastly, Codelgniter helps us create stable applications that will keep working for a long time and if done correctly, our applications can keep growing without it becoming a web of file after file of repeated code and functions. An important advantage of Codelgniter over plain PHP is that we can write more eloquent code, with which we can infer intent rather than have crypted code.
Codelgniter was made to enhance and expand PHP's own toolset. That is to say, it improves certain tools, for example database functionality or form handling that PHP has by itself in a somewhat limited way. Codelgniter also simplifies and abstracts certain aspects of PHP so as to encourage exploiting PHP and Codelgniter to the maximum. While Codelgniter is a solid solution, we may have different needs and this means that we should be aware of other frameworks and the needs that they may solve.
A great example of this is Laravel which has a lot of similarities with Ruby on Rails, both in functionality and philosophy. It's documentation and simplicity have made Laravel a favorite among seasoned programmers. Symfony is another great option whenever you need to tackle a very large and complex challenge. It would not however, make much sense to use Symfony on a simple application. Zend is another great option to look at, simply because it has the backup of the creators of the current PHP engine.
It also comes with a bunch of testing and debugging tools even on production environments, which is rare among frameworks. Now that we have a clear view of what Codelgniter is, let's go ahead and set up our local environment.
- Loading views and data from containers
- Routing with controllers
- Creating models
- Configuring the data
- Working with data, forms, sessions, and headers
- Logging and error logging
- Extending CodeIgniter to consume dependencies