A Query7 reader requested this tutorial to be written. It’s aimed to be a general guide to build ‘something’ using Code Igniter. It uses Models, Views, Controllers, Helpers and Libraries and will give you a good idea how Code Igniter works as a whole. I will be posting more advanced Code Igniter tutorials in the future.
Setup
Install and do some basic configuration (URL, database settings) of Code Igniter. If you don’t know how to do this, read here. Autoload the database library and url helper as we will be using them.
The user will be able to post new items and delete current items and the app itself will be made up of:
- One Controller – todo.php
- One Model – todo_model.php
- One View – todo_index.php
PHP4 Compatibility
Because Code Igniter supports both PHP4 and PHP5, you are forced to use PHP4 style OOP. Your constructor must be the same name as the class, and it needs to contain parent::Controller(); or parent::Model();
The naming conventions for controllers and models are very strict. The name of both class and constructor must be the same as the file name, but capitalized. In our case of our controller,…
Recently, a client of mine wanted a single web form, residing on the localhost to submit the form contents to a database in the localhost, and as well as to a web server simultaneously. Although this sounds like an unnecessary duplication of data, my client wanted some of the form data to be stored on the localhost for the intranet applications to use. Achieving this functionality would have been a piece of cake, if we were not handicapped by the unavailability of cross-domain AJAX. For those of us familiar with AJAX, we know that we cannot send an AJAX request to a remote server due to security reasons – atleast not in a reliable, hack-less way.
So, instead of looking for a pure AJAX solution, I decided to implement this functionality by using a combination of AJAX (for the localhost) and a traditional PHP POST request (for the web server). The trick here is to execute the AJAX call before the form is submitted – by catching the form submission event using JavaScript. Once the AJAX call is successful, we allow the default form submission to take place. In case there is an error with our AJAX call, we should…
Not yet released, FLOW3 starts making noises on the mass: what’s TYPO3 up to?
As a result of the already proven TYPO3 CMS, the upcoming 5th version of the system is bringing a solid PHP framework, which can be used apart from the whole system for developing applications of any kind.
The FLOW3 subsite stats, against what’s commonly seen out there, FLOW3 is not a pick’n’mix store of motley components. It’s a framework which helps you with the infrastructure of your application. Object Lifecycle Management, Package Management, Resource Management and Security are on his home field. Real business logic is left over to third-party packages.
All the most common features we can find in other PHP frameworks are going to be provided by FLOW3, like MVC architecture, Validation, Filters, Persistence Object Manager and much more.
Next week, I’ll post a getting started with a simple application and provide my personal review of this framework, which – OMHO – is going to rock!