Welcome Guest, Not a member yet? Register   Sign In
Extending Base Libraries via. "Packages"

Version: CI 2.0 (Default Install)

Hi, I am experiencing unexpected results. It seems that you cannot extend base libraries through packages. In my particular instance I was trying to extend form_validation class.
Since this is not a core class It must be stored in the ./application/libraries. My attempt at storing it in ./package_path/libraries was unsuccessful. Here is my final solution to the issue, however I feel it is more off a hack than a solution.

//I included the class myself

class MY_Form_validation extends CI_Form_validation {
    * Constructor
    function __construct($rules)

/* End of file MY_form_validation.php */
/* Location: ./packages/libraries/MY_form_validation.php */

And here is my controller

class PAGE_EXAMPLE extends CI_Controller {

    function __construct()

    function index()
        //Rest of method...

/* End of file PAGE_EXAMPLE.php */
/* Location: ./application/controllers/PAGE_EXAMPLE.php */

Let me know what you guys think


You can extend a library though a package, only the 'autoloading' of the extended class doesn't happen as you have discovered.

A cleaner solution might be to extend the loader library so that it looks in packages as well?

Theme © iAndrew 2016 - Forum software by © MyBB