Home > ANM_Class, CodeIgniter, PHP > ANM_CI – CodeIgniter Integration Library

ANM_CI – CodeIgniter Integration Library

March 28th, 2009

Table of Contents

Getting Started

References

[ Back to top ]

Introduction

ANM_CI is a PHP class which is developed to use as a CodeIgniter’s user library. This library integrates CodeIgniter with ANM technology which is able to achieve 100% satisfaction of programmers while using CodeIgniter because of its efficiency, simplicity and usefulness. I encourage you to use the library to see that how it makes your life so easy & comfortable.

[ Back to top ]

Download

Version Release File Name File Size Download
0.9.0 28 March, 2009 anm_ci-0.9.0.zip 6.6 KB Download
anm_ci-0.9.0.tar.gz 5.4 KB Download

[ Back to top ]

Installation

  • Download the ANM_CI compressed library (zip/tar.gz) and uncompress it.
  • After uncompress you will have a directory named anm_class with following structure:
    • anm_ci.php – the ANM_CI library
    • license.txt – license of the library
    • docs – documentation directory
      • anm_ci_manual.html – user guide for the library
      • style.css – stylesheet of the user guide
      • anm_ci_example.php – an example controller implementing all the properties and methods of ANM_CI
  • Now place the directory under
    {codeigniter_system_dir}/application/libraries

[ Back to top ]

How to Use?

To load the library simply use CodeIgniter’s loader class.

$this->load->library( 'anm_class/anm_ci' );

You can also set it as CodeIgniter’s auto-loading resource. To do it just open the autoload.php file from{codeigniter_system_dir}/application/config

and add ‘anm_class/anm_ci’ as an array element of $autoload['libraries']

$autoload['libraries'] = array('anm_class/anm_ci');

Once you include it in auto-loading library list then you don’t need to load the class in your script.

Now use the library as follows:

$this->anm_ci->remap( $method, $rules );

[ Back to top ]

Change Log

  • This is first release, so no changes yet.

[ Back to top ]

License

This library is licensed under The MIT License which is given with this library. If not available please visit http://www.opensource.org/licenses/mit-license.php

[ Back to top ]

Credit

ANM_CI is developed by A.N.M. Saiful Islam who is a Computer Science Graduate and currently working as a Software Engineer with Future Group Bangladesh.

[ Back to top ]

Property Reference

  • ci – Instance of the main CodeIgniter object

[ Back to top ]

Method Reference

  • remap – Remap given method according to given remap rules
  • redirect – Redirect current page to given URI

[ Back to top ]

ci

Description

This is an instance of main CodeIgniter object. It is a public property. So you can use it anywhere where anm_ci library is accessible.

Typically this object is used to load and access CodeIgniter recourses like library, view, model, database, scaffolding, vars, helper, plugin, file, lang, config etc. You can use the above ci object as an alternate of the CodeIgniter’s this object.

Example

$this->anm_ci->ci->load->model('Model_name');

is equivalent of

$this->load->model('Model_name');

Note

You’ll notice that the ci property is being passed by reference. This is very important. Assigning by reference allows you to use the original CodeIgniter object rather than creating a copy of it.

[ Back to top ]

remap

remap( string method, array rules [, string default] )

Parameters

  • method – Typically second segment of the URI
  • rules – Rules to decide which method will be called by which name
  • default – Method which will be called if requested method is not available

Description

The remap method integrates CodeIgniter’s built in _remap method which is used to overwrite the behavior of calling controller methods over URI. To know details about using the _remap method you can read the article: CodeIgniter _remap method – Power and Benefits.

Typically programmers design the _remap method using multiple if-else or switch control structure so that the _remap method looks like:

                    function _remap( $method )
                    {
                        switch( $method ) {
                            case 'index':
                              $this->index();
                              break;

                            case 'contact':
                              $this->contact_us();
                              break;

                            default:
                              $this->page_not_found();
                              break;
                            }
                    }
                    

But while using ANM_CI you will use an associative array as the alternate of the multiple if-else or switch control structure. The examples from bellow explain the implementation of the above script in terms of ANM_CI technique.

Example

Using ‘default’ router rule:

                function _remap( $method )
                {
                    $rules = array(
                        'index'   => 'index',
                        'contact' => 'contact_us',
                        'default' => 'page_not_found'
                        );

                    $this->anm_ci->remap( $method, $rules );
                }
                

Using third parameter:

                function _remap( $method )
                {
                    $rules = array(
                        'index'     => 'index',
                        'contact'   => 'contact_us',
                        'not-found' => 'page_not_found'
                        );

                    $this->anm_ci->remap( $method, $rules, 'not-found' );
                }
                

Note

If you use a ‘default’ key in your rules array, the value of default key will be considered as default method which you can also pass in the optional third parameter. If you use third parameter then default key will be ignored as default method. Here default method is the method which will be called if requested method is not available.

[ Back to top ]

redirect

redirect( [string uri [, array method [, int http_response_code]]] )

Parameters

Same as CodeIgniter’s redirect helper function.

Description

It works same as CodeIgniter’s redirect helper function. The extra benefit is, if CodeIgniter’s redirection does not work properly it tries to redirect using HTML meta tag and JavaScipt. If all the above attempts fail then it displays a redirection message with a link of the redirection URL.

Example

            function index()
            {
                $this->anm_ci->redirect( 'home-page' );
            }
            

[ Back to top ]

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • BlogMemes
  • email
  • LinkedIn
  • Live
  • Print
  • Taggly
  • TwitThis
  • Yahoo! Buzz

$@!ful ANM_Class, CodeIgniter, PHP , , , , ,

  1. November 28th, 2010 at 20:48 | #1

    I can’t download your library with error “The file you are trying to download is invalid.”
    Thanks for your sharing! ^^

  2. March 11th, 2011 at 15:30 | #2

    I can’t download your library…
    Thanks

  3. abdul
    December 24th, 2011 at 19:18 | #3

    what is use of that library

  1. No trackbacks yet.