Book Image

Programming with CodeIgniter MVC

Book Image

Programming with CodeIgniter MVC

Overview of this book

The CodeIgniter Model-View-Controller framework provides genius simplicity, flexibility, and efficient resource usage, boosting performance and reusability. "Programming with CodeIgniter MVC" reviews the unique features of CodeIgniter using simple, easy-to-follow, and practical examples. Programming with CodeIgniter MVC provides a simple step-by-step guide to efficiently utilizingthe CodeIgniter MVC framework for developing web applications. This book is packed with engaging examples to understand the usage of controllers, libraries, and (Codeigniter) CI Models. This book commences with a quick discussion of the CodeIgniter Integration with  external plugins such as Flickr API, Google Maps and more will be reviewed with clear usage examples. It will then cover CI naming convention rules, mandatory and optional configurations, and usage within a CI project. It will also cover user defined configurations. By the end of this book, you will not only understand user-defined libraries in a CI framework, but also their services, role, usage, and scope with the help of an example-based approach. The book also covers helpers, models, and views, as well as their usage. Using this book, youwill soonbe able to develop feature-rich web applications using the CodeIgniter MVC framework. "Programming with CodeIgniter MVC" is a one-stop solution to developing solutions with CodeIgniter MVC.
Table of Contents (15 chapters)
Programming with CodeIgniter MVC
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Appendix
Index

Example 3 – building your own helper


This example uses a helper to download a very large file, of 200 MB, which can't be downloaded in one file reading.

This example will be constructed from the following helpers:

  • application/helpers/my_download_helper.php: This is the CI helper that is used to download a very large file

  • application/controllers/classg2.php: This is the controller that uses the my_download helper

  • application/views/classg2view.php: This is the view that has a link for the file download

Let us assume that the URI to the project root is http://mydomain.com/myproject. Hence the URI to execute the auth controller for login will be http://mydomain.com/myproject/classg2.

Tip

The source code is provided with this book via URLs.

The helper file

This helper is used to download very large files, which can't be downloaded in one file reading. Its function, download_large_files, reads 1 MB in each loop until it downloads the whole file.

  <?php  if ( ! defined('BASEPATH')) exit('No direct script...