Your SlideShare is downloading. ×
Using Code igniter for PHP application development
With many software frameworks available online nowadays, with many pros...
Process of Codeigniter
The following graphic illustrates how data flows throughout the system:
1. The index.php serves as ...
• Since CodeIgniter lacks much of the automation, there are no strict conventions to follow.
This makes CodeIgniter a more...
like–but usually its passed along to a model function that queries what you want from a database.
Simple and straightforwa...
There’s plenty more to CodeIgniter than that, of course–you can create custom libraries and helpers,
and store configurati...
So, what’s Codeigniter good for?
I’ve written all kinds of applications with it, what some would consider the bread and bu...
Striking features of CodeIgniter
There are many features that are quite distinguishing, in CI. Few of the most important f...
is automatically validated by the validation object. Even certain error messages can also be automated the
same way, using...
Upcoming SlideShare
Loading in...5
×

Codeigniter

3,871

Published on

One of the effective PHP Frameworks is the Code Igniter. Web applications with advanced features can be readied using the Code Igniter. Simpler for the beginners, CI follows an MVC (Model View Controller) pattern, thereby enabling in easy learning. Also, due to the usage of conventional PHP coding, the existing codes can be ported using this PHP framework. Also the simplicity with which it works and the speed that it has when compared to the other frameworks, is definitely considerable.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,871
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
35
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Codeigniter"

  1. 1. Using Code igniter for PHP application development With many software frameworks available online nowadays, with many pros and cons on their side, it has become very important to check out complete details of these frameworks before applying them. Amongst the various kinds of software frameworks, the PHP Framework is more popular nowadays. Being simple to work on and easy to use, PHP frameworks are soon becoming the catchword of software frameworks Why we should use it? One of the effective PHP Frameworks is the Code Igniter. Web applications with advanced features can be readied using the Code Igniter. Simpler for the beginners, CI follows an MVC (Model View Controller) pattern, thereby enabling in easy learning. Also, due to the usage of conventional PHP coding, the existing codes can be ported using this PHP framework. Also the simplicity with which it works and the speed that it has when compared to the other frameworks, is definitely considerable.  Easy to install and use.  Good for applications utilizing multiple platforms.  Applications can be built quickly and easily.  Simple to debug.  Secured.  Developer Friendly  Its support every kind of 3rd party tools  The most important thing is you don’t need to be expert for use this but you can learn all other programming logics easy and quick while using this Why we should use it?  Code igniter is a lightweight web application framework written in PHP that adopts the model-view- controller approach to development  Web Application frameworks provide basic building blocks needed by most application o Database connections o Business logic o Form handling  Some are the features which kind be missed with this documentation o Feature Rich o Lightweight o Open Source o Well-supported by an active community o Excellent “by example” documentation o Easy to configure o Supports multiple database In short, Code igniter is nice because it does what it needs to do and then gets out of the way.
  2. 2. Process of Codeigniter The following graphic illustrates how data flows throughout the system: 1. The index.php serves as the front controller, initializing the base resources needed to run CodeIgniter. 2. The Router examines the HTTP request to determine what should be done with it. 3. If a cache file exists, it is sent directly to the browser, bypassing the normal system execution. 4. Security. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security. 5. The Controller loads the model, core libraries, plugins, helpers, and any other resources needed to process the specific request. 6. The finalized View is rendered then sent to the web browser to be seen. If caching is enabled, the view is cached first so that on subsequent requests it can be served. Limitations The first major issue with the framework is how it deals with retrieving and manipulating data from the database. • CodeIgniter's models are optional and serve no function other than code separation. There's no integrated CRUD and its "Active Record" class is really just an alternative SQL syntax. It also doesn't support table associations. So, you will be building many large queries essentially from scratch. • CodeIgniter lacks some essential libraries that are needed in most applications (i.e. Authentication and ACL). You will need to rely on 3rd party libraries in many of your applications.
  3. 3. • Since CodeIgniter lacks much of the automation, there are no strict conventions to follow. This makes CodeIgniter a more flexible framework. Furthermore, its lack of features and automation do give it an advantage when it comes to speed. Improving these limitations would give a great boost to the CodeIgniter framework and make it more powerful. Although some of the limitations are fixed via 3rd Party libraries or plugins it would be great to have them right out of the box. Developer Point of View It’s a flexible, compact, and simple Model-View-Controller (MVC) framework for PHP. If you’re as analytical as I am, you’re probably wondering why I’m using weasel words like flexible, compact and simple, so I’m going to drill down a bit to explain. I’m not going to give you any textbook explanations, either, just talk from the benefit of having written about 40 applications over the course of the last 2 years. Let’s go with the two most important things, at least for me as a developer: simple and compact. Compact because it is cut down to a manageable footprint. CodeIgniter 1.7.2 weighs in at 1.6 MB (as compared to 9MB for CakePHP). It contains various libraries and helpers to get you through all the tedious crap you’ll encounter in every project–form helpers to build forms, HTML helpers to replace the tedium of markup, and libraries for handling calendars, emails, ZIP downloads, basic shopping carts, encryption, FTP, languages, caching, pagination, and lots more. With CodeIgniter, use what you want, and ignore what you don’t. If there isn’t something already built-in, reach out to the community to get what you need, or extend CodeIgniter with your own helpers and libraries. What about “simple”? Well, with most projects, you’ll be breaking your code into three easy-to- understand areas. You organize your application using controllers. The functions in your controller make up your routes and paths. For example, if you have a path like this on your site: /store/category/123 Then that means you have a store controller with a category() function inside it. That function takes some kind of ID as an argument (in this case, “123″) and you can use that argument however you
  4. 4. like–but usually its passed along to a model function that queries what you want from a database. Simple and straightforward. Oh, by the way, if you don’t want to take the time to sanitize every single user input, you can adjust one config setting to have CodeIgniter do it for you. I tend to create lots of different controllers to keep my applications well-organized, but there’s no reason why you couldn’t just have one single controller for you project. CodeIgniter doesn’t really care, but if you’re working with other developers, having more controllers makes it easier to split up the work. Anything having to do with data is put into models–I tend to use separate models for different database tables, but you could flatten yours into just a few models. Some guys use a basic model that allows them to get one, get many, and so on, and just extend that into every situation. Inside each model are functions that do something specific with a database table. You could, for example, have a function that specifically pulls out a single category, all categories, or some other combination. In no way do your model names have to match your database table names. Nor do your database tables have to follow some kind of predesignated structure, with certain field names. This makes CodeIgniter an ideal framework for use with legacy data schemas. CodeIgniter doesn’t care that your key field is id or myID or foobarID, you tell it what you want in your model functions and it works. I’ve built some projects without any models at all–that’s right, CodeIgniter doesn’t really care. This is a handy thing to know if you’re just mocking up a static prototype. Just place all your static content in views and you’re done. Of course, you could put the static content into models, if you like. It’s up to you. One more note about your model functions. You can use CodeIgniter’s ActiveRecord functions to avoid the use of SQL altogether, or you can use raw SQL if you like. You can also download an object-relational mapping (ORM) library to abstract your data handling work even more, if that’s more your speed. It’s up to you. Everything the user sees on the screen is placed in views. Again, I tend to create a lot of views, and organize them into various folders for each set of controllers, but you could do whatever you wanted here. Adding client-side tools like jQuery is easy, too–just add a folder for your jQuery files and reference them in your views, and voila, you’re done. Start using jQuery. CodeIgniter doesn’t care.
  5. 5. There’s plenty more to CodeIgniter than that, of course–you can create custom libraries and helpers, and store configuration details in their own files, too–but you don’t have to do much with any of that. Just make a few config entries to find your server root and database install, and you’re ready to roll. What does all this mean? Well, if you’ve worked on any non-MVC PHP project, you know that things tend to get a bit messy. You end up with PHP files that contain SQL queries mixed in with your HTML, and config items are thrown in for good measure. If you’re experienced enough, you know to put your configuration strings into a global header include (for example) and to organize your functions and classes into separate files. Add enough developers, enough late nights, and enough crazy client requirements, and things start to slide into sloppy land. But here’s the thing–CodeIgniter’s MVC approach forces you to think smart, to think long-term, if you will, about your project, and start putting things in their proper places. Anything that deals with data goes in the model. Anything the user sees in a browser goes in the view. Anything that pertains to application structure or routes goes in the controller. If you need to refactor, you find yourself writing libraries and helpers. In fact, you’ll find very quickly that the controller provides an amazingly concise way to keep yourself on track. Customer reports a problem with a page, just ask for the path. Aha, the /store/category section is buggy? Open the store controller and look at the category() function. Looks like you’re running two model functions and building a view. Now you know how to proceed, and it doesn’t matter that it’s 3 a.m. and you haven’t slept in a long while. Throughout this piece, I hope I’ve made a case for CodeIgniter’s flexibility. Use what you need to get the job done, don’t use what you don’t need. CodeIgniter works with from-scratch data schemas, or ones you inherit. It has powerful libraries that allow you to add sophisticated functionality while still keeping the core of your application organized in a straightforward way.
  6. 6. So, what’s Codeigniter good for? I’ve written all kinds of applications with it, what some would consider the bread and butter of the web development world: * all kinds of content management systems * shopping carts and payment gateways * community forums and discussion boards * gadgets and widgets that connect to social media APIs, such as Twitter * custom data-entry applications, such as contact databases * any application that requires lots of calculation, such as billing and invoicing * any application that integrates with a web service, or uses FTP or email extensively * any application that deals with calendaring or event management In particular, CodeIgniter really shines if you’re inheriting or upgrading legacy code or legacy data structures. In my particular line of work, I find myself rewriting apps that have seen better days, and in every case, I’ve never had a lick of problems with the underlying data structure (unless of course, the schema was bad and needed redoing, but that’s a whole other story). I’ve also had a great deal of success using CodeIgniter in dynamic project situations, where the customer requirements seem to change every week–change requests show up, and I can react quickly with solid code.
  7. 7. Striking features of CodeIgniter There are many features that are quite distinguishing, in CI. Few of the most important features are explained below: User Guide One of the most important features of the CodeIgniter is that it has a very impressive user guide. The way the documentation has been done is simply marvelous and highly useful for coders to know more about the working. Simplicity CodeIgniter is simple and a major portion of the work gets completed in the controllers and uploading the libraries. Since the workings are clear and open, it is very easy to understand what is happening and therefore, simple to use. Model Handling While working with models, CodeIgniter uses a straight way of handling. Standard SQL queries can be mimed using few simple commands. Also creation of model objects, loading it and introducing methods to deal with a customized task is also possible. Data Validation Data validation is a major thing while working on models. Here a validation class is used to validate data. First, few rules are defined and assigned to the object to be validated. The data that is sent through the URL
  8. 8. is automatically validated by the validation object. Even certain error messages can also be automated the same way, using data validation class. There are many other advantages of using CI: Migration from one server to another is easier and hassle-free. Also installation is easier as well. CI is very easy to handle and also to customize. In case a new functionality has to be applied, it can be done without affecting the customization. With MVC based framework, it offers flexibility and easy management. Active Record Implementation is simply superb and easy to remember. Configuration and customization of these configuration files are also easy, thus facilitating easy working with various types of developers. The collection of libraries that it posses is also good enough. And as previously said, awesome documentation of the user guide, which makes any coder easy to use the whole framework. i i http://philsturgeon.co.uk/blog/2012/12/5-things-codeigniter-cannot-do-without-a-rewrite

×