Welcome Guest, Not a member yet? Register   Sign In
Library's parameters load with MAMP, but will not load when placed on server?
#1

[eluser]elvis2k[/eluser]
Newbie first post. Any help is much appreciated!

My custom library's parameters will not load when on a server, but load fine when using MAMP.

I have written a custom library which lives in:
application/libraries/MYcustom.php

"MYcustom" library uses a parameter array from a config file which lives in:
application/config/MYcustom.php

The library's constructor:
function MYcustom($params = array()){
$this->params = $params;
}

Reference to the library in a controller:
$this->load->library('MYcustom');
$this->mycustom->doSomething();

This set-up is working fine on MAMP.

But when everything is uploaded to my server, the library's parameters do not load.
I'm not seeing any other errors.
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums!

The issue is usually an issue with case-sensitivity. I don't know if Macs are case-sensitive (as it's based on Linux), but I know Linux is fussy about case.

I'm also not sure about your MY prefix. Please could you give the actual file name you're using, and the contents of the file?

You only need to use MY if you're overriding an existing CodeIgniter library, and even then, by default the prefix is "MY_".
#3

[eluser]elvis2k[/eluser]
Thanks for the reply.

Ha, well the "MYcustom" is fake name for this post.

Actual file names:
application/libraries/OSUcommonContent.php
application/config/OSUcommonContent.php

Controller calls:
$this->load->library('OSUcommonContent');
$this->osucommoncontent->helloWorld();

Library constructor:
function OSUcommonContent($params = array()){
$this->params = $params;
}
#4

[eluser]TheFuzzy0ne[/eluser]
I don't see where the parameters are passed in to your libraries constructor. Am I missing something?
#5

[eluser]elvis2k[/eluser]
[quote author="TheFuzzy0ne" date="1239318720"]I don't see where the parameters are passed in to your libraries constructor. Am I missing something?[/quote]

I'm just doing what the guide says, and it works in MAMP:
Quote:
Simply create a config file named identically to the class file name and store it in your application/config/ folder

http://ellislab.com/codeigniter/user-gui...aries.html

Inside the config file I have this:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
        // basic settings for osu common content library
        $config = array(
            'path' => '../2008/',
            'menu_type' => false
            etc...
        );        
?>
#6

[eluser]TheFuzzy0ne[/eluser]
[DELETED]
#7

[eluser]TheFuzzy0ne[/eluser]
I'd suggest changing your file name so that either the whole name is lowercase, or only the first letter is capitalised:

./system/libraries/Loader.php - line 860
Code:
function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
    {    
        // Is there an associated config file for this class?
        if ($config === NULL)
        {
            // We test for both uppercase and lowercase, for servers that
            // are case-sensitive with regard to file names
            if (file_exists(APPPATH.'config/'.strtolower($class).EXT))
            {
                include_once(APPPATH.'config/'.strtolower($class).EXT);
            }            
            else
            {
                if (file_exists(APPPATH.'config/'.ucfirst(strtolower($class)).EXT))
                {
                    include_once(APPPATH.'config/'.ucfirst(strtolower($class)).EXT);
                }            
            }
        }

This could be made a bit clearer in the docs. Please consider reporting this.
#8

[eluser]elvis2k[/eluser]
Many thanks! Renaming worked!

Library and Config file names:
Osucommoncontent.php

Controller calls:
$this->load->library(‘Osucommoncontent’);
$this->osucommoncontent->helloWorld();

Library constructor:
function Osucommoncontent($params = array()){
$this->params = $params;
}




Theme © iAndrew 2016 - Forum software by © MyBB