Welcome Guest, Not a member yet? Register   Sign In
Creating and using libraries
#1

[eluser]Knitter[/eluser]
Hi,

I've created a few libraries, since that was the only way I found to have my classes work properly withing CI, but I'm having problems loading some of them.

Being libraries I followed the docs for their creation, but one of them is not loading correctly, or not loading at all. All of them are in the autoload array.

I have a library name Toolbar, in it I create an array with Menu objects. The Toolbar class loads correctly, but the Menu class will always fail.
The Toolbar's constructor is something like:
Code:
public function  __construct() {
        $barra = array();

        $barra[] = new Menu('Início', 'inicio', false);
        $barra[] = new Menu('Automóveis', 'automoveis', false);
        $barra[] = new Menu('Eventos', 'eventos', false);
        ....

With this constructor I have the classic "Fatal error: Class 'Menu' not found".

If I comment out the use of the Menu object, and I leave the Menu class in the autoload array for libraries I get
Quote:Severity: Warning

Message: Missing argument 1 for Menu::__construct(), called in (...)/libraries/Loader.php on line 928 and defined

Filename: libraries/Menu.php

I understand that CI is trying to instantiate my class, or am I wrong? If so, why is CI trying to create an instance of the object, is the autoload responsible for creating the instances?

How do I get around this without having to include every php file with the classes I need? I would really prefer to use my own autoload special function that would load every class I use, instead of having to manually include the files, but that, I think, would mess up CI.
Any suggestions?


Messages In This Thread
Creating and using libraries - by El Forum - 09-30-2009, 04:09 PM
Creating and using libraries - by El Forum - 10-01-2009, 07:11 AM
Creating and using libraries - by El Forum - 10-01-2009, 08:44 AM
Creating and using libraries - by El Forum - 10-01-2009, 02:13 PM
Creating and using libraries - by El Forum - 10-01-2009, 02:38 PM
Creating and using libraries - by El Forum - 10-01-2009, 02:49 PM
Creating and using libraries - by El Forum - 10-01-2009, 02:58 PM
Creating and using libraries - by El Forum - 10-01-2009, 03:04 PM
Creating and using libraries - by El Forum - 10-01-2009, 03:47 PM
Creating and using libraries - by El Forum - 10-01-2009, 04:03 PM
Creating and using libraries - by El Forum - 10-01-2009, 05:29 PM
Creating and using libraries - by El Forum - 10-01-2009, 08:02 PM
Creating and using libraries - by El Forum - 10-01-2009, 08:22 PM
Creating and using libraries - by El Forum - 10-06-2009, 12:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB