You are not logged in.

Important Note: This forum is being archived and will be completely locked down on the 7th of February. The new forum can be found at http://laravel.io.

Announcement

    Laravel 4 Advanced Architecture: Book Now On Sale

#1 2012-10-26 03:00:41

bill
Artisan
Registered: 2012-09-05
Posts: 50

Problem autoloading Codeigniter library

Hi everyone,

I'm trying to import a library/model I have developed in an old CI project. But I am having trouble getting it to work.

The classe's filename is is

list_model.php

I have placed it in the application/libraries folder, and modified it so it begins like:

<?php 


class List_model {
    //var $variable;
    //var $variable;
    
/**
 * 
 * 
 * 
 */
public static function email_attachment($address,$subject='HI', $attachment_path=NULL) {

I have also changed most of the classes functions to public static. In my controller though when I call a function from this class ( e.g.

$result =list_model::safe_csv($filepath, $data);

, I get :

Message:

Class 'list_model' not found

Can anyone give me a hand with this.

Thank you,

Bill

Last edited by bill (2012-10-26 03:02:08)

Offline

#2 2012-10-26 04:52:16

Syropian
Artisan
From: Toronto
Registered: 2011-07-30
Posts: 299
Website

Re: Problem autoloading Codeigniter library

I could be wrong, but I think using an underscore will break libraries, because it'll treat the first part like a namespace. Try calling the class ListModel instead.

Offline

#3 2012-10-26 05:09:32

tuna.abutbul
Artisan
From: localhost
Registered: 2012-10-24
Posts: 32

Re: Problem autoloading Codeigniter library

you must call the class like this: "List_model::safe_csv"
PHP *something* *something* uppercase *something* ( yea.. F**k my English..)


Thanks and sorry for my poor English
-- Tuna Abutbul.

Offline

#4 2012-10-26 10:35:08

Phill Sparks
Quality Team
From: Leicester, UK
Registered: 2011-09-29
Posts: 1,480
Website

Re: Problem autoloading Codeigniter library

Syropian, you're partly right.  Underscores are treated as directory separators, so List_Model becomes libraries/list/model.php.  Alternatively you could map all the classes using the Autoloader::map function.

Offline

#5 2012-10-27 02:01:28

bill
Artisan
Registered: 2012-09-05
Posts: 50

Re: Problem autoloading Codeigniter library

Thanks guys, Its working now.

Regards,

Bill

Offline

Board footer

Powered by FluxBB

');